Human Motion Project

My original idea is to make a walking robot or a dancing robot with two servo motors as its legs. Also, I would have two knobs that control the movement of each leg. The whole setup was not hard to make. However, it turned out much more difficult than I imagined.

My robot cannot stand the imbalance

The balance was a big problem. When one leg moves, the other leg tends to wobble, making it impossible for the robot to move forward. I then tried to walk forward with only one leg moving at a time. It is impossible to move forward without shifting the centre of gravity by adjusting the other leg. Therefore, I reglued the sticks to the sides of the paper cups and made them more stable. The following is the code I used:

#include <Servo.h>

Servo myservoL; // create servo object to control a servo
Servo myservoR;

int potpinL = A5; // analog pin used to connect the potentiometer
int potpinR = A3;
int valL; // variable to read the value from the analog pin
int valR;

void setup() {
myservoL.attach(9);
myservoR.attach(11);

}

void loop() {
valL = analogRead(potpinL); // reads the value of the potentiometer (value between 0 and 1023)
valL = map(valL, 0, 1023, 0, 90); // scale it to use it with the servo (value between 0 and 180)
valR = analogRead(potpinR);
valR = map(valR, 0, 1023, 0, 90);

myservoL.write(valL); // sets the servo position according to the scaled value
delay(15);
myservoR.write(valR);
delay(15); // waits for the servo to get there
}

Leave a Reply

Your email address will not be published. Required fields are marked *