Cuckoo Clock

Submitted by MarieSpliid on Tue, 04/02/2013 - 21:44
MarieSpliid's picture

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); 
}

 

clock1.jpg
clock2.jpg
clock3.jpg
clock4.jpg
clock5.jpg
0
Your rating: None
Drupal theme by Kiwi Themes.