Seema Hari, Noriko Misra, Vaidyanath Venkitasubramanian, & me
This assignment was a lot of fun. We built a rectangular linkage and attached to a servo which oscillated in a 65 degree space. We came to this number mostly by trial and error, starting with 90 and then narrowing down.
Short video of working cuckoo: https://www.sparkcamera.com/v/2mumPwI0Kr
Longer and arguably more entertaining video: https://www.sparkcamera.com/v/zBPH3v8FpB
// 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
int pos = 45; // variable to store the servo position
void setup()
{
Serial.begin(9600);
myservo.attach(7); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 165; pos > 100; 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(15); // waits 15ms for the servo to reach the position
}
for(pos = 100; pos<=165; pos+=1) // goes from 180 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
}
Serial.println(pos);
delay(1500);
}
- Login to post comments