Description:
After toying around with a number of designs, I settled on one that works intermittently, but covers a lot ground when it works just right. I connected the servo motor to a set of legs made from a wire hanger. I put an eraser on each leg to give it more traction. Then using a box and some other tools, I propped it up in the back so that when the motor moves a leg forward, the whole body leans one direction. That shifts weight and allows the other leg (which is further back) to swing way forward unobstructed. When the motion works right, it slides/walks forward quite a bit. The trouble is that the body's attachment to the servo motor is a little loose so the pieces tend to move out of place. I also haven't been totally able to control for the weight disparities between front and back. I added a balance beam in the back to help keep things from tippig over, but it's still no match for the power of the servo motor when things get out of line.
If I were really going to go for it, I'd restart with much stronger body connections, but that'd require additional components that I didn't have on hand. Overall, it "walks!"
See it in action: http://youtu.be/6x6kRUb095g
Parts used:
(1) Arduino Uno board
(1) Breadboard
(1) Potentiometer
(1) Servo Motor
(3) Extension wires to create mobility
(1) Paper clasp
(4) Rubber bands
(1) Wooden dowel
(1) Plastic stick
(1) Servo box
(3) Pencil head erasers
Arduino Code:
Note: I didn't modify what we used in class because I couldn't get the machine to act consistently that it would run off preset code. It feels more like a remote control car, where modest adjustments are necessary by the controller in order to keep the bot moving forward as its balance/conditions change.
/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* October 11 2007
*/
int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer
int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from potentiometer
int minPulse = 500; // minimum pulse width
void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("servo_serial_better ready");
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
if (val > 0 && val <= 999 ) {
pulseWidth = val*2 + minPulse; // convert angle to microseconds
Serial.print("moving servo to ");
Serial.println(pulseWidth,DEC);
}
updateServo(); // update servo position
}
// called every loop().
void updateServo() {
// pulse the servo again if the refresh time (20 ms) has passed:
if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}
- Login to post comments