The Santa Catcher
2. Concept
The Santa Catcher is a fun today for kids that is designed to catch Santa. The toy works by detecting motion using a PIR sensor, then alerts the computer, and outputs jingle bells and Rudolph the red nose reindeer.
3. References and Prior Art
http://www.instructables.com/id/Arduino-Basics-PIR-Sensor/
http://makezine.com/projects/pir-sensor-arduino-alarm/
http://www.arduino.cc/en/Tutorial/melody
4. Processes and Fabrication
After stumbling across a motion-sensor tutorial video I was inspired to incorporate a PIR sensor in my design. The design is composed of a PIR sensor, purchased at Radio Shack, connected to the arduino board. When the PIR sensor is activated a signal passes to a piezo buzzer that plays festive music. The sensor sends a message to the serial monitor that says, “Motion detected” and states, “motion ended” when the motion stops. I wanted to include a colorful light display therefore I created another program that played music and lights together. When I combined the PIR program with the lights/music, the speaker stopped working. I know that these outputs are totally possible although. I intended this project to be an ornament that would play festive music when someone moves in the space.
5. Application/ Functionality
There is much room to take this project further, such as creating ornaments, wreaths, and other decorations.
Code:
by Nelle McDade December 2013
With Reference to:
// Uses a PIR sensor to detect movement, buzzes a buzzer
// more info here: http://blog.makezine.com/projects/pir-sensor-arduino-alarm/
// email me, John Park, at jp@jpixl.net
// based upon:
// PIR sensor tester by Limor Fried of Adafruit
// tone code by michael@thegrebs.com
int ledPin= 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
int speakerPin = 10;
int length = 35; // the number of notes
char notes[] = “eeeeeeegcdefffffeeeddedg gagecagacac”; // a space represents a rest
int beats[] = {1,1,2,1,1,1,1,1,1,1,4,1,1,1,1,1,1,2,1,1,1,1,2,2,4,2,2,2,2,1,1,1,1,1 };
int tempo = 250;
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = { ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘a’ };
int tones[] = { 1915, 1700, 1519, 1432, 1275,1136 };
// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}
void setup() {
pinMode(speakerPin, OUTPUT);
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop() {
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
for (int i = 0; i < length; i++) {
if (notes[i] == ‘ ‘) {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
// pause between notes
delay(tempo / 2);
digitalWrite(speakerPin, LOW);
}
delay(150);
if (pirState == LOW) {
// we have just turned on
Serial.println(“Motion detected!”);
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
digitalWrite(speakerPin, LOW);
delay(300);
if (pirState == HIGH){
// we have just turned of
Serial.println(“Motion ended!”);
// We only want to print on the output change, not state
pirState = LOW;
}
}
}