Introduction: Adding a Face and Covers to Your Robot
This Instructable is about adding a face to your robot with LED eyes. Build the robot here.
Step 1: Materials & Tools
You will need these materials for this project:
(1) Robot
(2) 5 MM LED's
(3) feet of 22 AWG wire
Cardboard
Hot glue
Solder
Tools you will need for this project:
Utility Knife
Hot Glue gun
Soldering iron
Step 2: Solder the LED Assemblies
Solder the LED's positive leads to the 200 ohm resisters.
Next solder the LED's negative leads together.
Then solder three wires to the assembly as shown.
Step 3: Cut Out and Assemble the Face
Cut out a rectangle that fits the face.
Poke two holes where you want the eyes.
Glue the LED's in place.
Wrap the wires with electrical tape a few inches down.
Step 4: Install the Face
Glue the face in place on the robot's head.
Connect the negative on the face to the ground on the robot.
Then connect the positive leads on the LED's to D1 and D2 on the Arduino.
Step 5: Front and Back Covers
Cut a rectangle for the back. You may have to cut a small recess to accommodate the stabilizer.
Glue the top of the cover to the top edge of the back.
Cut another rectangle that fits the entire front of the robot.
Score a line between section A and section B.
Glue the top of section B to the top edge of the front of the robot with the score facing up.
Now glue a strip of cardboard to the bottom edge as pictured to hold on the front cover.
Step 6: Arduino Code
Here is the code to make your robot eyes blink. Upload this to the Arduino on your robot.
//// include the library "servo.h".
#include ///// name the LEDs.
const int LED1 = 11; const int LED2 = 12; ////name the controller buttons.
const int button1 = 2; const int button2 = 3; const int button3 = 4; const int button4 = 7; const int button5 = 8;
//// define servos.
Servo servoLeft; // Define left servo. Servo servoRight; // Define right servo. Servo servoTop; // Define upper head servo. Servo servoNeck; // Define lower head servo.
//// set the enishole value of the controler butons to 0.
int buttonState1 = 0; int buttonState2 = 0; int buttonState3 = 0; int buttonState4 = 0; int buttonState5 = 0; void setup() { servoLeft.attach(10); // Set left servo to digital pin 10 servoRight.attach(9); // Set right servo to digital pin 9 servoTop.attach(5); // Set servoTop to digital pin 5 servoNeck.attach(6); // Set servoNeck to digital pin 6 //// define the LEDs as outputs. pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT);
//// define the controler butons as inputs. pinMode(button1, INPUT); pinMode(button2, INPUT); pinMode(button3, INPUT); pinMode(button4, INPUT); pinMode(button5, INPUT); }
////////this code plays over and over in a loop.
void loop() { buttonState1 = digitalRead(button1); buttonState2 = digitalRead(button2); buttonState3 = digitalRead(button3); buttonState4 = digitalRead(button4); buttonState5 = digitalRead(button5); if (buttonState3 == HIGH) { forward(); delay(50); } else { stopRobot(); digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); } if (buttonState4 == HIGH) { reverse(); delay(50); } else { digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); stopRobot(); } if (buttonState2 == HIGH) { turnRight(); delay(50); } else { digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); stopRobot(); } if (buttonState1 == HIGH) { turnLeft(); delay(50); } else { digitalWrite(LED1, LOW); digitalWrite(LED2, HIGH); stopRobot(); } if (buttonState5 == HIGH) { Up(); delay(50); } else { digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); stopRobot(); } if (buttonState2 and buttonState1 == HIGH) { Laugh(); delay(50); } else { digitalWrite(LED1, LOW); digitalWrite(LED2, LOW); stopRobot(); } if (buttonState3 and buttonState4 == HIGH) { Jiter(); delay(50); } else { digitalWrite(LED1, HIGH); digitalWrite(LED2, LOW); stopRobot(); } }
//////// funcshins void forward() { servoLeft.write(0); servoRight.write(180); }
void reverse() { servoLeft.write(180); servoRight.write(0); }
void turnRight() { servoLeft.write(180); servoRight.write(180); }
void turnLeft() { servoLeft.write(0); servoRight.write(0); }
void stopRobot() { servoLeft.write(90); servoRight.write(90); servoTop.write(90); servoNeck.write(90); }
void Up() { servoTop.write(50); servoNeck.write(90); }
void Laugh() { servoTop.write(90); servoNeck.write(20); }
void Jiter() { servoTop.write(90); servoNeck.write(130); }