Drawer-Pop Cuckoo Clock

Submitted by stlim on Tue, 04/02/2013 - 22:39

Description

This cuckoo clock is operated by one servo motor. Drawer-like door opens as the bird pops up and makes sound to signal the time.

 

The servo motor makes the drawer move forward (open) and lifts the bird. Its partial rotation is conveyed to the two parts through wires. A wheel translates it into another rotational movement to pop up the bird. A pipe translates it into linear motion of the drawer.

 

Components Used

- 1 arduino uno board

- 1 potentiometer

- 1 servo motor

- wire, beam, cardboard, wheel, ... , so many kinds of materials!

 

Initial Design

Attached below.

 

Video Demo

http://youtu.be/UKkIvxoGYXs

 

Code

/*

  Lab8
  This lab uses servo motors to create a cuckoo clock
  
 */
 
#include <Servo.h>
 
#define HIGH_NOTE 880
#define LOW_NOTE 784
#define NOTE_DELAY 150
#define NUM_REPEATS 2
 
// pin definitions
Servo servo;
int potentiometer = A0;
int speaker = 10;
 
void setup() {
  servo.attach(9, 3500, 6350);
  Serial.begin(115200);
}
 
void loop() {
  /*
  // map ADC reading (0-1023) to angle (0-180)
  int angle = map(analogRead(potentiometer),0,1023,0,180);
  
  // limit angle of servo
  if(angle > 120)
    angle = 120;
    
  // play tone when bird is out
  if(angle < 40) {
    tone(speaker, 440);
  } else {
    noTone(speaker);
  }
  Serial.println(angle);
  servo.write(angle);
  */
  int flag = analogRead(potentiometer);
  if(flag == 0) {
    int angle;
    for(angle = 120; angle > 0; angle--) {
      servo.write(angle);
      delay(5);
    }
    for(int i = 0; i < NUM_REPEATS; i++) {
      tone(speaker,HIGH_NOTE,NOTE_DELAY);
      delay(NOTE_DELAY);
      tone(speaker,LOW_NOTE,NOTE_DELAY);
      delay(NOTE_DELAY);
    }
    for(angle = 0; angle < 120; angle++) {
      servo.write(angle);
      delay(5);
    }
  }
}
 
drawer_cuckoo_0.jpg
0
Your rating: None
Drupal theme by Kiwi Themes.