Description
This was one of the more difficult projects because we have only 180 degrees of motion. To create a crawler, I had to try everything I had around the house. This took a few hours of tinkering with boxes, forks, velcro, etc.. I finally came up with the idea to use a round object because it could slide under itself after moving. I remember a toy from Toy Story 1 that used a hand to pull itself forward. I tried to recreate that with this project. I wound up using a round speaker my friend had laying around. It was heavy enough to balance itself. However, there was no way of stopping it from rolling forward. To remedy this, I used a popper toy to stop it from rolling too far ahead. This proved to be an effective means of stopping its forward momentum and weighing it down.
Next, I had to make sure I had a material that could "catch" the carpet. This wound up being a fork, because it had ends that could insert into carpet. I added a second fork to reinforce the first one and make sure it pressed down on the ground. I had the code alternate between 0-70 degrees of rotation, the best angle for my crawler. By entering values into the serial console, I am able to adjust the speed of the crawler in ms. It changes the delay between the two rotations. This makes it faster or slower. This was a little wonky because I could only increase values (not decrease). When I open the serial console again, I start at 200ms again (the default value I set).
Materials Used
1x Stick
1x Popper Toy
2x Forks
1x Arduino Uno
Various Wires
Code
#include <Servo.h>
Servo servo1; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int val = 200;
int val2 = 0;
void setup()
{
int val = 200;
int val2 = 0;
Serial.begin(9600); // connect to the serial port
Serial.println("Servo control program ready");
servo1.attach(7); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = val + val2;
val2 = Serial.read(); // read the serial port
Serial.print("Time between servo movement: ");
Serial.println(val,DEC);
for (pos = 0; pos < 70; pos += 1) // goes from 0 degrees to 70 degrees
{ // in steps of 1 degree
servo1.write(pos); // tell servo to go to position in variable 'pos'
delay(8); // waits 15ms for the servo to reach the position
}
delay(val);
for (pos = 70; pos>=0; pos-=1) // goes from 70 degrees to 0 degrees
{
servo1.write(pos); // tell servo to go to position in variable 'pos'
delay(8); // waits 15ms for the servo to reach the position
}
}
- Login to post comments