Robot Cupid With Moving Head, Lights and Sound
by snorlaxprime in Circuits > Arduino
556 Views, 0 Favorites, 0 Comments
Robot Cupid With Moving Head, Lights and Sound
I was inspired to add a few addition to the cute robot cupid to make it more alive because it is a robot and it is also Valentine's day. I recycle my light activated MP3 player circuit. The same circuit is also being used in the Frankenbot instructables.
Create Your Instructables Robot Cupid
Follow the awesome instructions to create your instructables robot cupid. But don't glued the body to the head just yet. We are going to put some circuit that will make it nodding it's head and lighting up the lights.
Other things that I had change is to glue the paper to thicker cardboard like cereal boxes. But it makes it harder to bend and you will need to adjust the thickness for the head so that the part to hold the candy will fit into the body.
The Circuit and the Part List
As you can see in the circuit above, I am using arduino nano as the brain to the robot. The servo motor is controlled via pin 9 to move the head up and down. The MP3 player is used to play your favourite love song when the LDR (light sensor) is activated. You can put the robot in the box and when it is open, the light sensor will activate the song. When it is activated I am also flashing the 3 LEDs that is mounted to the chest of the robot.
Here are the list of the parts used:
- Arduino Nano
- DFPlayer mini
- 3 LEDs
- Mini Speaker
- 1K resistor x2
- 330 ohm resistor
- Servo motor
- LDR
- String to connect the servo to the robot head
- Paper clip to hold the string
Make Holes to the Chest
The robot is not complete without a blinking lights, so we poke some holes to fit the 3 LEDs to the chest. Be gentle and don't break it's heart.
Then fit the 3 LEDs to the chest.
Assemble the Circuit and Coding
Assemble the circuit. I added the servo connected to the pin 9 of Arduino. The servo comes with 3 wires. Black or brown wire to be connected to GND. the Middle Red wire to be connected to VCC (5V) and the Yellow wire is the control which is connected to Pin 9 of Arduino.
The initialisation for the servo is done in the following section of the code:
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store servo position
The other modification from Frankenbot circuit is to have the MP3 song called 002.mp3 located in folder 07. The initialisation of the code is as follow:
int Song=2; //sd:/07/002.mp3
Then initialise the servo add the following code to the Setup section of the code
void setup()
... myservo.attach(9); // attaches the servo on pin 9 to the servo ... }
{
The servo can only rotate 180 degrees by design, so it is like a wiper, the code to move the servo is as below:
for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 90 degrees
// in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 90; pos >= 0; pos -= 1) { // goes from 90 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position }
The code above will move the servo up to 90 degrees and then turn it back to zero position.
One more minor thing. If you use the code from Frankenbot, it was designed to activate when it is dark, so you will need to change the logic to activate when there is light instead. This is done in the following section of the code.
if (ldrStatus > 200){ //light up when open ... //Blink the LED here and play the song, you can adjust the 200 threshold // if the room is too bright or too dark }
Now you can upload the code to arduino and test that everything works ok. Don't forget to upload your favourite love song into the SD card inside the folder sd:/07/002.mp3, if you are using my code, or you can change this to something else.
I had uploaded the full code for your convenience.
Downloads
Assemble the Servo
Now that you know the circuit is working, it is time to out the circuit into the robot. The first thing to do is to poke a hole at the back and install the servo. Then the tricky bit is to put all the rest of the circuit into the bottom compartment. Shown in picture 3. I had also poke another hole to be able to power the circuit. Then you will have to glue everything together. But don't glue the back of the head first, as you will need to connect a string hold by a paper clip.
Because I am sticking the paper to the cardboard, it is much harder to glue, so I am using some paper clip to assist holding things together.
Final Touches
Now that everything is assembled, it is time to connect the string to the back of the head, I hold the string using a paper clip. Sorry I forgot to take the photo before I glued the head together. Then attached the string to the servo. My string is a little to short, so the mouth is not closing as well, you can adjust the string to make sure that you get the desired effect.
Then glue the hand and the wing for the finishing touches. If you notice my LDR is poking out in the back corner of the robot mouth. I would suggest to put this in the front chest too.
The last step is to power up and enjoy your cupid bot coming to live. It is time to impressed your loved one with some surprises stored in it's mouth and have a Happy Valentine's day.
I hope you had enjoyed making this robot as much as I enjoy making them. Please leave a comment or if you have any questions, I will be more than happy to answer them. Thank you for reading my instructables.