To make a crawler, the first thing that came into my mind was chopsticks. So I gather a few chopsticks, break them, and them try to put them together in a way that would make the single-legged servo motor crawl. It took some observation and reiteration. I used a lot of tapes and a few coins to adjust the balance. Now this robot is really crawling.. but not in a straight line.. It seems to be moving towards Northwest…
Arduino Code
#include
Servo myservo;
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; 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(4); // waits 15ms for the servo to reach the position
}
delay(200);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(4); // waits 15ms for the servo to reach the position
}
delay(200);
}