Description
In this lab I worked with Kristina Hart to construct a walker that uses two servo motors to move forward. For the body of the walker, we used the small servo motor box (see video). One servo motor was placed inside of the box such that the shaft of the motor protruded from a specially cut section on the side of the box. Affixed to the shaft of this servo (servo 1) is a green pencil eraser that serves as the leg that propels the walker forward. The other servo motor (servo 2) is attached to the top of the box. Servo 2 works in coordinated conjunction with servo 1 by lifting the entire body of the walker so that servo 1 can reset the its leg allowing the walking motion to be repeated. Servo 2 lifts the motor through the use of a white rectangular pencil eraser with composite board piece attached to the bottom that moves vertically up and down on the front side of the walker. There is also a specially designed path cut into the body of the crawler that guides the path of Servo 2's leg. A full traveling cycle of the walker is completed as follows:
a. Servo 1 and 2 are in resting states rotated so that neither legs are touching the ground. Servo 1's leg is pointing in the direction that the walker will travel.
b. Servo 1 rotates clockwise and in doing so, drags the green leg against the ground propelling the walker forward until the green leg has rotated and is no longer in contact with the ground, now pointing behind the walker.
c. Servo 2 rotates counterclockwise, and in doing so, moves the white eraser down into contact with the ground and continues to rotate until the front part of the body of the walker has been lifted off the ground.
d. Servo 1 rotates counterclockwise until the green leg has been reset to its starting position, having rotated without making contact with the ground.
e. Servo 2 rotates counterclockwise until the white eraser leg has been lifted off the ground completely and now the servos are in the positions that they started in, in orientation a. This process repeats to produce forward movement.
Components
2- Arduino Uno Microcontrollers
2- Breadboards
2- USB Cables
2- Apple Laptop Computers (Mac OSX)
2 - Futaba S3003 Servo Motors
2 - Potentiometers
1- Futaba S3003 Servo Motor Box
4- Needle-point pins
4 - Pieces of a Cork (so that the pins would not be dangerous)
2 - Pencil erasers
1 - Piece of composite board
Scotch Tape
Code
(This code was used by each of the operators to control each leg independently.)
/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* October 2013
*/
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
}
}
Video
http://myhub.pixorial.com/watch/432142fa3b304b9bf5061f21b279acdf
- Login to post comments