The stride of the crawler is set by the potentiometer. The servo motor rotates from 0 degree to the degree set by the potentiometer. User first rotates the pot to a value between 0 to 179 degree, then keys in 's' in the Serial monitor to set the stride. The servo then continues to rotate to that degree to make the crawler crawl. To quit crawling, user can key in 'p' in the serial monitor. This will stop the crawling
The crawler is made of two pieces cut off from a credit card, and a piece of wood wrapped around by a rubber band. There were holes drilled on the credit card legs and the piece of wood so that they can be tied together using strings (they were dental floss actually). The legs were then tied onto the servo motor. The rubber band increases the surface friction.
Components
1- Arduino Uno
1- Breadboard
1- Servo Moter
1 - Potentiometer
2 - pieces of cut up credit card
1 - piece of wood board
some dental floss and twist wires
Code
##### sample code borrowed from Arduino.cc website Knob example ####
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int setStride = 0;
int potPin = A0;
int serialVal;
int val;
int quit = 0;
void setup()
{
myservo.attach(7); // attaches the servo on pin 7
Serial.begin(9600);
}
void loop()
{
if (setStride != 0 && quit==0)
{
for(pos = 0; pos < val; pos += 1) // goes from 0 degrees to the degrees set by the pot
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = val; pos>=1; pos-=1) // goes from pot degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position