Description:
The goal of the assignment was to explore using the servo motors and to make a crawler.
I partnered up to make a two servo motor design. The original goal was to make a flipper. One servo motor would flip the device 180 degrees. This would place the device in the position for the second servo motor to flip the device again.
We tried to design a device that would be self-contained and house the Arduino with independent 9V power source.
However, as we designed the device, we discovered that the servo motors did not have enough torque to push the device up and over with the added weight of the electronics and battery. Also, it was a challenge to put everything in place in a self-contained device.
Components Used:
1- Breadboard
1- Arduino Uno
1- 9V Battery
1 USB interface cable to Arduino
2 servo motors
Various spare wood for container.
Code
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo myservo2;
int pos = 30; // variable to store the servo position
void setup()
{
myservo.attach(7); // attaches the servo on pin 7 to the servo object
myservo2.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 150; pos>=30; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos);
delay(5); // waits 15ms for the servo to reach the position
}
for(pos = 30; pos < 150; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos);
delay(5); // waits 15ms for the servo to reach the position
}
delay(500); // Wait for first motor to get into start position
for(pos = 0; pos < 150; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos = 150; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
delay(500);
}
- Login to post comments