Video: https://youtu.be/ukvsB9rwcKE
Our group’s ideas ranged far and wide for this one, but after considerable debate we realized we wanted to create a project with at least the following characteristics:
- Halloween themed, with a
- Nontraditional door, and which
- Respects the cuckoo-clock MO
With these parameters in mind our project became clear to all of us all at once: an egg that hatches a skeleton cuckoo bird through an egg shell door.
We started with a cardboard model, which we then measured and recreated in Fusion 360. For our hinge and door mechanism we decided to employ a “living hinge” design that we laser cut from plywood. We actuated the door with a gear and crank glued to the inside of the box, and added a second gear to drive a rack at the base of our bird design. As the gears turn the bird is propelled upwards and the lid opens.
We had some ideas about how to give the bird some personality, too, by having it “peep” when it reached the top of its stroke. We were able to do this on a timer, and had plans to incorporate a microphone so that a loud noise would startle the bird out of its shell. While we did include the mic in our schematic, a little more work is needed on the code to get that particular functionality set up.
Materials:
Plywood, 1/8″
Small servo motor
Wires
Arduino Uno
Wood glue
Machine screws
SparkFun Mic
Breadboard
Piezo Speaker
Code:
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
const int sampleWindow = 250; //250 MS sample width
unsigned int loudNoise;
int speakerPin = 7;
int val = 0;
int orig = 0;
int potPin = 0;
void setup()
{
pinMode(speakerPin, OUTPUT);
Serial.begin(9600);
Serial.println(“ready”);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
unsigned long start= millis(); // start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
Serial.print(“loudNoise”);
Serial.print(loudNoise);
Serial.println();
while (millis() – start < sampleWindow) // collecting data for 250 MS (can be changed)
{
loudNoise = analogRead(0);
if (loudNoise < 1024) //
{
if (loudNoise > signalMax) // if there’s a loud noise, save the loud value
{
signalMax = loudNoise;
}
else if (loudNoise < signalMin) // if there’s not a loud noise, don’t save the loud value
{
signalMin = loudNoise;
}
}
}
peakToPeak = signalMax – signalMin; // max – min = peak-peak amplitude
double volts = (peakToPeak * 3.3) / 1024; // convert to volts
Serial.println(volts); // to know if the mic is working
// digitalWrite(speakerPin, LOW);
//myservo.write(180);
//val = analogRead(potPin); // read value from the sensor
//val = val*30; // process the value a little
//val = val/2; // process the value a little
if (volts >=1.0){
for( int i=0; i<50; i++ ) { // play it for 50 cycles
for(pos = 180; pos>=0; pos-=9) // 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
};
delay(6000);
for(pos = 0; pos <= 180; pos += 3) // 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(80); // waits 15ms for the servo to reach the position
};
delay(500);
for(int j=0; j<50; j++){
digitalWrite(speakerPin, HIGH);
delayMicroseconds(800);
digitalWrite(speakerPin, LOW);
delayMicroseconds(800);
};
};
}
//if (volts >=1.0) {
// delay(2000); // for a certain amount of time (though this could be modified for more expressive behavior)
// Serial.println(“YELLING AT US”);
// }
// else {
// digitalWrite(12, LOW);
// digitalWrite(2, LOW); //not yetlling at us
// };
else {
myservo.write(0);
delay(1000);
}
};