Description:
I had so much fun assembling this crawler, thinking about the mechanics of a one-legged crawler, and how weight would need to be distributed to get it to move in a linear direction. While hardwood floor doesn’t allow for enough friction between it and the tips of the paperclips, the knit of my scarf produced similar (but slightly better) results. I discovered that my crawler crawls best on a surface with some teeth to it, such as the cover of one of my sketchbooks. Through experimentation I discovered that in order to get it to walk straighter, I needed to reprogram the arduino such that it didn’t have the servomotor have one single sweeping pattern.
Components Used:
- 1 Arduino
- 1 Servomotor
- 1 Breadboard
- 1 pot (but unused in the sketch below)
- 1 large paperclip, 1 medium paperclip
- 1 Futaba servomotor box
- 1 X-factor nail polish bottle
- electrical tape
Code:
/* * Servo Control Serial * modified for TUI October 2007 * Servo Serial Better * ------------------- * * Created 18 October 2006 * copyleft 2006 Tod E. Kurt <tod@todbot.com> * http://todbot.com/ * * adapted from "http://itp.nyu.edu/physcomp/Labs/Servo" */ #include <Servo.h> Servo myservo; // create servo object to control a servo int servoPin = 7; // Control pin for servo motor int pos = 0; // variable used to store data from serial port int minPulse = 0; // minimum pulse width int maxPulse = 100; // maximum pulse width void setup() { pinMode(servoPin, OUTPUT); // Set servo pin as an output pin pos = minPulse; // Set the motor position to the minimum Serial.begin(9600); // connect to the serial port Serial.println("Servo control program ready"); myservo.attach(7); // attaches the servo on pin 9 to the servo object } void loop() { for (pos = minPulse; pos <= maxPulse; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(7); // waits 7ms for the servo to reach the position } for (pos = maxPulse; pos >= minPulse; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(5); // waits 5ms for the servo to reach the position } } AND ALSO /* * Servo Control Serial * modified for TUI October 2007 * Servo Serial Better * ------------------- * * Created 18 October 2006 * copyleft 2006 Tod E. Kurt <tod@todbot.com> * http://todbot.com/ * * adapted from "http://itp.nyu.edu/physcomp/Labs/Servo" */ #include <Servo.h> Servo myservo; // create servo object to control a servo int servoPin = 7; // Control pin for servo motor int pos = 0; // variable used to store data from serial port int minPulse = 0; // minimum pulse width int maxPulse = 115; // maximum pulse width int correction = 55; int count = 0; void setup() { pinMode(servoPin, OUTPUT); // Set servo pin as an output pin pos = minPulse; // Set the motor position to the minimum Serial.begin(9600); // connect to the serial port Serial.println("Servo control program ready"); myservo.attach(7); // attaches the servo on pin 9 to the servo object } void loop() { for (count = 0; count <= 2; count +=1) { for (pos = correction; pos <= maxPulse; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(7); // waits 7ms for the servo to reach the position } for (pos = maxPulse; pos >= correction; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(5); // waits 5ms for the servo to reach the position } } for (count = 0; count <= 7; count +=1) { for (pos = minPulse; pos <= correction; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(7); // waits 7ms for the servo to reach the position } for (pos = correction; pos >= minPulse; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(5); // waits 5ms for the servo to reach the position } } }