Voice Activated One Bird Clock

by MikeTheMaker in Circuits > Clocks

4469 Views, 10 Favorites, 0 Comments

Voice Activated One Bird Clock

image for square.jpg
Firmly say "Time" and this bird will count the hours by bobbing forward and the minutes (in multiples of five) by bobbing backward.  He does a little "wobble" between hours and minutes so that you will know, "the times, they are a changing."





 

one bird16.jpg
An Arduino "listens" for sounds and operates a servo motor to display the time.

Major materials needed:

Arduino    Radio Shack
small servo motor     amazon.com
drinking bird     amazon.com
acrylic butter dish     homeandwine.com
breadboard     jameco.com
2n2222a      jameco.com 
2 microfarad capacitor     jameco.com
9 volt dc power supply     jameco.com
microphone    jameco.com

one bird flow.jpg
Above is an abbreviated flow diagram for the software.

Software:

#include <Servo.h>

int ledPin = 13;
int minute=0;
int hour=7;  //start time at 7
int valm=0;
int valm1=0;

Servo myservo;

static unsigned long lastTick = 0; // set up a local variable to hold the last time we moved forward five minutes
// move forward five minutes every 300000 milliseconds

void setup() { //set outputs and inputs
myservo.attach(5);
pinMode(ledPin, OUTPUT);

}

void loop() {


if (millis() - lastTick >= 300000) {
lastTick = millis();
minute++;


}


// move forward one hour every 12 five minute intervals
if (minute >=12) {
hour++;
minute = 0; // reset minutes to zero
}

if (hour >=13) {
hour=1;
minute = 0; // reset minutes to zero
}
valm=analogRead(0);
if(valm>400){
   delay (10);
   valm=analogRead(0);
   if(valm>300){
     digitalWrite(ledPin, HIGH);
     //bird dunk
     if(hour == 1) {
       myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     }
   if(hour ==2) {
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
   }
  if(hour == 3) {
   myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
  }
if(hour == 4) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 5) {
myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
    myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 6) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 7) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 8) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 9) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 10) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 11) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
if(hour == 12) {
  myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
     myservo.write(10);
     delay(500);
     myservo.write(90);
     delay(500);
}
//separate movement between hours and minutes
myservo.write(80);
delay(500);
myservo.write(100);
delay(500);
myservo.write(80);
delay(500);
myservo.write(100);
delay(500);
myservo.write(90);
delay(500);
if(minute ==1) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute ==2) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 3) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 4) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 5) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 6) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 7) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 8) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 9) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 10) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
}
if(minute == 11) {
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
  myservo.write(170);
  delay(500);
  myservo.write(90);
  delay(500);
   }
   digitalWrite(ledPin, LOW);
   }}

  


valm1 = analogRead(1);    // add five minutes when pressed
if(valm1<800) {
minute++;
delay(250);
}
 


}

one bird schematic.jpg
one bird07.jpg
Wire up the microphone assembly on the breadboard.

one bird01.jpg
Separate the drinking bird from his legs.  Drill a couple of holes on one side of the leg assembly and glue the servo motor (I used Gorilla glue) to the legs.

one bird02.jpg
Drill a hole in one side of the bird's "axle."

one bird17.jpg
Drill a hole in the servo arm.

one bird03.jpg
Fasten the servo arm to the bird with a screw.

one bird05.jpg
Twist the bird "axle/servo arm" assembly and screw the arm into the servo motor.

one bird06.jpg
Twist the bird/arm into its final position.  Tape the end of the arm to secure it and prevent slippage.  I used aluminum duct tape.

one bird08.jpg
Connect the Arduino to your computer and upload the software.

Place double sided tape on the Arduino and breadboards. Stick them to the butter dish.

one bird09.jpg
one bird10.jpg
Cut the end off the cable that comes from the servo motor  (red, black, white).

one bird12.jpg
Solder one end of a jumper wire to each end of the servo cable.

one bird14.jpg
one bird15.jpg
one bird16.jpg
Plug all the wires into place.

one bird13.jpg
Plug the clock in--it will default to seven o'clock.  

Each press of the red button will advance the clock five minutes.  If the time is 8:15, press the red button 15 times.

You may want to stop occasionally and say "Time" to the bird--making sure you don't overshoot your target time.

That's it--enjoy!