Introduction: Shy Robot

A simple entertainment project using arduino that can keep you entertained for a very long time; a robot that will duck away from you if you try to touch it.

Supplies

Things you'll need:

- Arduino Uno

- Arduino software

- USB cable to connect Arduino

- Breadboard

- TG9e Servo + Servo horn

- LDR sensor

- 2x LED

- Resistor (gold-red-black-brown)

- Resistor (gold-brown-red-red)

- Connector cables (short and long length)

- Conductive wire

- Pliers

- Tape

- Cardboard

- Heat lamp

- Decorative paint/extra's

Step 1: Step 1: the Wiring

Copy the following wire setup onto your arduino.

Attach wires of corresponding color to your servo as you pin it to your arduino to more easily keep track of your wires. You can pin multiple LEDs to row 12 and 13 in this setup, do make sure the long end of your LEDs are pinned to row 13, and the short end to row 12.

Please be aware that you will need to weld some cable extensions to your LDR sensor and your LEDs to properly incorporate them into your robot. If you have access to welding materials you can easily do this by welding the LEDs and LDR to some connector cables, if you don’t you can reliably attach the cables by wrapping your LED/LDR and connector cable together with some conductive wire using pliers before isolating the connection with some tape.

Step 2: Step 2: the Code

copy the following code to your arduino program and upload it to your board:

#include <Servo.h>

Servo servo;

void setup() {

Serial.begin(9600);

servo.attach(9);

pinMode(11, OUTPUT);

pinMode(A0, INPUT);

}

void loop() {

int value = analogRead(A0);

Serial.print("value=");

Serial.print(value);

Serial.println(value);

int pos = map(value, 400, 1023, 0, 180);

Serial.print(", mapped=");

Serial.println(pos);

servo.write(pos);

analogWrite(11, value/9);

}

Connect your Arduino to your PC using the USB-cable, verify the code and then upload it to your Arduino.

The ‘ analogWrite(11, value/9);’ line of code dictates how bright your LEDs will burn and how noticeably they will change color, I recommend experimenting with values between 6 and 15 to see which value works best for the kind of lamp you are using at home.

Step 3: Step 3: Design Your Robot

The base of the robot consists of a 10x10x4 cm cardboard box, with a slot cut in the bottom from which the servo will prop up the box, and a hole in one of the corners of the box from which we will run all our wiring to the arduino.

With this base design in place you can have fun designing your own kind of robot! just be mindful to mark where on your box you want your LEDs and LDR sensor to be placed before you start decorating, since the wiring of these components will need a bit of room.

Step 4: Step 4: Setting Up Your Robot

After you’ve designed and decorated your robot it’s time to attach the technical parts to it.

Carefully cut or drill holes into the spots you marked for your LEDs and LDR and run the corresponding wires through the holes, reinforce your LED/LDR with some extra tape on the inside of the box if necessary before leading the wires through the inside of the box and back out the corner hole of the box to attach them to your arduino.

Attach the servo to the bottom of your box (either by using tape, glue, or wire depending on your preference) so that the servo horn props up your box. Lead the wiring for the servo through the corner hole of the box along with the wires for your LEDs and LDR. Be careful of your cable management, and make sure no wires are in the way of the servo. Otherwise there is a risk of the wires getting caught on the servo horn and pulling your wiring.

After youve done this connect the wires to your arduino per step one and attach the arduino to your PC. Your robot should now work!

Step 5: Optional:

You could make an extra box to hold your arduino and breadboard for your robot, this will both give your wiring some extra security as well as make your setup more cohesive.

If you have access to a metal workshop you could make the robot out of actual metal, I advice using something light like tin or aluminium, so that the servo is under less stress. Do be aware that you will need to thoroughly isolate all your wiring before doing this however! As any bare metal parts of your wiring touching the metal of your robot would cause a short circuit.