Cuckoo Clock
This is our Cuckoo Clock for the simple mechanics assignment. The video below shows how the doors open and close automatically. The bird is not automated yet, but the motor for the bird already runs.
Components
- 2 servo motors
- Arduino
- Bread board
- string, cardboard, paper, metal string, wooden sticks, plastic tubes, plastic wheels, tape, etc.
Code
#include <Servo.h>
Servo doorServo;
Servo duckServo;
int pos = 0;
void setup()
{
doorServo.attach(7);
duckServo.attach(8);
}
void loop()
{
//open doors
for (pos = 0; pos < 130; pos += 1)
{
doorServo.write(pos);
delay(20);
}
delay(500);
//move duck forward
for (pos = 0; pos < 110; pos += 1)
{
duckServo.write(pos);
delay(20);
}
delay(500);
//move duck backwards
for (pos = 110; pos >= 0; pos -= 1)
{
duckServo.write(pos);
delay(20);
}
delay(500);
//close doors
for (pos = 130; pos >= 0; pos -= 1)
{
doorServo.write(pos);
delay(20);
}
delay(2000);
}
- Login to post comments
Drupal theme by Kiwi Themes.