Introduction: Shybot, the Distance Activated Dancing Robot

A few weeks ago I was talking to a classmate about our fear of failure. The fear that one day we would have to present a project and see it fail in front of our teachers. This is where the idea for Shybot began. This robot is not supposed to work when you're watching it from nearby. Shybot is shy, so you'll have to take a few steps back. When you're far enough he will start dancing!

I decided to create a dancing robot because dancing is a big passion of mine. I myself tend to get stage fright, so to turn my fear into the strength of my concept seemed like an amazing challenge to overcome my fear failure.

Supplies

Ultrasonic sensor, 9V Battery with holder, 6X Servo SG90, Breadbord, Arduino UNO, Wires M/F and M/M.

Step 1: The Circuit

Connect the components as shown in the image. The order of the servos is important! From left to right the order is:

- Left arm

- Left thigh

- Left foot

- Right foot

- Right thigh

- Right arm

Note that in the image it looks like I used one AA battery, but this is supposed to be one 9V battery!

Step 2: Print 3D Files

In the file, the robot has already been dissembled, so it's ready to print! Don't forget to add support. I printed mine with 0,8 mm PLA and 0,5 draft quality. I chose these settings due to a deadline, but I would definitely recommend using a smaller size for better detail. I had to clean most of the edges because the Arduino components did not fit at first.

Step 3: Assemble Shybot

Assemble Shybot according to the image in step 2. Make sure you add the attachment on the servos before the actual servos. If you screw on the attachments first, some of the pieces won't fit anymore!

The breadboard, Arduino and Ultrasonic sensor will click into place!

I used some glue to keep the servos in place while screwing them on!

The battery compartment is a bit big for one 9V battery. This is because it was originally designed for 3 AA batteries, but these were not strong enough to run the code.

Step 4: The Code

#include
#include

//creating variables Servo leftfoot; Servo rightfoot; Servo lefthip; Servo righthip; Servo leftarm; Servo rightarm;

NewPing sonar(10, 6);

const int motorPin = 8;

int beat = 200; // if you decide to add music you can change the beat so Shybot will dance to the rythm

void setup() { Serial.begin(9600);

pinMode(motorPin, OUTPUT); leftfoot.attach(3); // left foot rightfoot.attach(9); // right foot lefthip.attach(11); // left thigh righthip.attach(5); // right thigh leftarm.attach(12); // left arm rightarm.attach(4); // right arm }

void loop() {

digitalWrite(motorPin, LOW);

int distance = sonar.ping_cm(); Serial.println(distance);

if (distance < 20 && distance >= 0) { // movement for shaking when you stand to close leftfoot.write(0); rightfoot.write(90); lefthip.write(90); righthip.write(105);

leftarm.write(0); rightarm.write(0);

digitalWrite(motorPin, HIGH);

delay(50);

leftfoot.write(10); rightfoot.write(100); lefthip.write(100); righthip.write(115);

leftarm.write(15); rightarm.write(15);

delay(100); }

if (distance < 190 && distance > 20) { // not moving leftfoot.write(0); rightfoot.write(90); lefthip.write(90); righthip.write(105);

leftarm.write(0); rightarm.write(0);

delay(1000);

}

if (distance >= 190) { // dancing! Feel free to change the routine! leftfoot.write(0); lefthip.write(90); rightfoot.write(90); righthip.write(90); leftarm.write(50); rightarm.write(180); delay(1000);

leftfoot.write(10); delay(beat);

rightfoot.write(60); lefthip.write(150);

leftarm.write(160); rightarm.write(50);

delay(beat);

righthip.write(150); leftfoot.write(40); lefthip.write(90);

delay(beat);

rightfoot.write(60); righthip.write(105);

leftarm.write(0); rightarm.write(0);

delay(beat);

lefthip.write(50); righthip.write(50); leftfoot.write(0); rightfoot.write(90);

delay(beat); rightarm.write(50); righthip.write(150); lefthip.write(150);

delay(beat); rightarm.write(0); lefthip.write(50); righthip.write(50);

delay(beat);

rightarm.write(50); righthip.write(150); lefthip.write(150);

delay(beat);

leftfoot.write(0); lefthip.write(90); rightfoot.write(90); righthip.write(90); leftarm.write(50); rightarm.write(180); delay(1000);

leftfoot.write(10); delay(beat);

rightfoot.write(60); lefthip.write(150);

leftarm.write(160); rightarm.write(50);

delay(beat);

righthip.write(150); leftfoot.write(40); lefthip.write(90);

delay(beat);

lefthip.write(50); righthip.write(50); leftfoot.write(0); rightfoot.write(90);

delay(beat); rightarm.write(50); righthip.write(150); lefthip.write(150);

delay(beat); rightarm.write(0); lefthip.write(50); righthip.write(50);

delay(beat);

rightarm.write(50); righthip.write(150); lefthip.write(150);

delay(beat);

delay(1000); } }

Step 5: That's It!

Feel free to change the code to create different Shybot reactions!

Maybe it will help to use stronger servos as well, so it will give you more motion range without getting stuck in place.