Emotion Detecting Robot That Actually Does Stuff
by jackmmaker in Circuits > Raspberry Pi
45 Views, 1 Favorites, 0 Comments
Emotion Detecting Robot That Actually Does Stuff

)
Meet Emobot, a robot that can detect your mood and then play music based on it or help you through what your are feeling. This music it plays can be curated by you! I am a student in 8th grade right now, and this robot was designed using Tinkercad.
Supplies

Electronics:
Raspberry Pi 4b
Half Size Breadboard
Micro SD card (preferably above 8GB)
USB Speaker (https://a.co/d/b1Xzlqx)
USB Camera (https://a.co/d/iSeAdCd)
Male-to-Female Jumper Wires
Male-to-Male Jumper Wires
1x otherparts.stl
1x body.stl
1x bottom.stl
Flash the Raspberry Pi

Take a micro SD card and insert it into your computer. Download the raspberry pi imager from here. Choose Raspberry Pi 4 from the choose device menu. From the choose OS menu select the Raspberry Pi OS 64 bit option. Select your SD card from the menu and press next. Click edit settings and input your wifi network and password and make sure SSH is enabled. Take note of the hostname and change it is you like. Finally, click yes and then yes. Once it's done, put the SD card into the Raspberry Pi.
SSH Into Your Raspberry Pi

If you don't know how to SSH into your raspberry pi, follow this guide. Just scroll down to Connecting to your pi via SSH.
Download the Github Repo

Once you are connected to your raspberry pi, type "git clone https://github.com/jgame123/emotionrobot" (Without the quotes). If you would like to add some of your own music for each emotion, just cd into the emotionrobot directory and then add your music to the respective folder. Next, run the command "pip install deepface" to install the python library that I use to detect emotions. Finally, run "pip install pygame".
Make the Program Run at Boot

Type "cd" and press enter to return to your home directory. Next, we are going to make a script that we can run at boot. Type "nano script.sh" and type the following in:
#!/bin/bash
cd emotionrobot
python main.py
Then press control and x, then y, then enter to save it. Next, type "chmod +x script.sh". This will make the script executable. Finally, we want to make this script run when we turn on the raspberry pi. To do this, type "sudo nano /home/pi/.bashrc". Next, use the down arrow key to scroll all the way to the bottom of the file. Press enter a few times then type "/home/pi/script.sh". Finally, press control and x together, then y, then enter to save it.
Add a Power Button

To add a power button to our Raspberry Pi so we can safely turn it off, type "sudo nano /boot/firmware/config.txt". Use the down arrow key to scroll all the way to the bottom of the file and press enter a few times. Then, put in the following: "dtoverlay=gpio-shutdown". Finally, press control and x together, then y, then enter to save it. Congratulations! This is the final step for the software.
Add the Camera

Take the camera and put the lens through the small square hole above the row of large holes (the button holes). Make sure it is right side up by seeing if the text on the front of the camera is readable. The cord should be coming out of the bottom. Tape the top of the camera down.
Insert Breadboard Supports

Take the two flat rectangles and insert them into the holes below the buttons holes (there is paper on my pieces in the paper, this is because the prototype pieces were slightly too small. Your pieces will be the right size). Then take the two pieces that have the hook like protrusion and insert those into the holes above the button holes. There should be some resistance, but just push them in.
Add Spacers

Glue the two rectangular posts above and below the button holes. The placement doesn't really matter so long as the top post doesn't touch the camera.
Wire the Breadboard and Buttons


Place the raspberry pi into the outline on the bottom piece. Don't put the push buttons on the circuit yet. Put a jumper wire from GPIO 17 on the raspberry pi to column 28 on the breadboard. Put a jumper from a ground pin on the raspberry pi to the ground row on the breadboard and take another jumper and put it from the ground row to column 30. Take a female to male jumper and put it from GPIO 3 to column 14. Take a male to male and put it from the ground row to column 16. Take a jumper and put it from GPIO 27 to column 1. Take the last jumper and put it from the ground row to column 3.
Get the Buttons Ready

Take a button and take out the support from the hole in the bottom. Then, take a pole and glue it into that hole. On the other end of the pole apply a spot of glue and then put a push button onto it. Make sure the button is oriented as it is in the picture. Repeat for the other buttons.
Put the Breadboard In

Take the breadboard and slide it into place on the supports with the jumper wires on the bottom. You might need to add some tape like I did so that the breadboard stays parallel to the wall.
Attach the Buttons
.jpg)
Take a button and push it into the spot it belongs in on the breadboard. The triangle should go on the right, the square on the left, and the power button in the middle. Thank you for reading! Your robot is now ready. Plug it in and make a face!