Arduino Powered Halloween Pumpkin With Motion Detection
by mronki in Circuits > Arduino
2813 Views, 30 Favorites, 0 Comments
Arduino Powered Halloween Pumpkin With Motion Detection
Hi,
this Instructable will show you how to make some Halloween decorations including arduino powered Halloween pumpkin with motion detection.
Making Halloween Pumkin
Materials:
- Round balloon
- Old newspapers
- Smooth flour
- Water
- Tempera
- Modeling clay
- Superglue
Tools:
- Brush
- Scalpel
- Pencil
To make your Halloween pumpkin first you should blow a balloon to a size you want your pumpkin to be. Newspapers should be cut into small pieces (for example 2X4cm). Next step is to glue pieces of a paper on a balloon. To do that first you have to make a glue of water and smooth flour. You should mix water and flour in a 1:4 proportion (for example on one cup of a water you should use 4 cups of a flour). To fix papers on a balloon, put glue on each peace. You can use brush to put glue on a paper. Whole balloon should be omitted with a paper and that process should be repeated 10 times to make structure even more solid.
You should wait 24 hours to make sure everything is dried up. You can then paint your pumpkin with orange tempera. To make sure color won't be transparent that process should be repeated two times. It's important to wait around 6 hours between putting colors first and second time. To make your pumpkin even more realistic you can paint vertical lines with a light brown tempera.
To start cutting your pumpkin you should wait additional 48 hours for everything to dry up. To make cutting process easier you can use pencil to draw eyes, nose and mouth of a pumpkin. Then you should cut ii using scalpel. To make pumpkin even scarier and to have a hole in which you can put Arduino and other electronics you should cut pumpkin around top of her head.
At the end you can make petiole using modeling clay and paint it using tempera. To fix petiole on a top of pumpkin head you can use superglue.
Electronics
This project uses Arduino to control sensors and LEDs. Five red LEDs are used to light the pumpkin. Two LEDs should be put inside a mouth, two in the eyes and one on a sliced part of a head. PIR motion sensor should be put in pumpkins nose. Green LED should be put inside pumpkin head and it's used to indicate when PIR sensor is calibrated. Buzzer should be put inside a pumpkins mouth. Servo motor should be put on top of the pumpkins head facing each other so they can lift sliced part.
Arduino turns LEDs, motors and buzzer on when PIR sensor detect motion. Buzzer then plays the scary melody (Halloween theme), servos are lifting sliced part of the pumpkins head and red LEDs are lighting up the atmosphere.
Parts:
- 1 x Arduino (any kind) - eBay
- 6 x 220 Ohm resistor - eBay
- 5 x Red LED - eBay
- 1 x Green LED - eBay
- 2 x Servo Motor - eBay
- 1 x Buzzer - eBay
- 1 x PIR motion sensor - eBay
- 1 x Breadboard - eBay
- Few wires (M/M and F/F) - eBay
- Battery (or you can cut a little hole on a Pumpkin and power it trought computer)
Wiring:
First servo motor:
- vcc to 5V on Arduino
- gnd to gnd on Arduino
- signal to digital pin 9 on Arduino
Second servo motor:
- vcc to 5V on Arduino
- gnd to gnd on Arduino
- signal to digital pin 11 on Arduino
Red LEDs:
- anodes (longer leg) to 220 Ohm resistor who is connected to digital pins 2,3,4,5,6 on Arduino
- cathodes (shorter leg) to gnd on Arduino
Green LEDs:
- anode to 220 Ohm resistor who is connected to digital pin 10 on Arduino
- cathode to gnd on Arduino
Buzzer:
- one leg to digital pin 8 on Arduino
- other to gnd on Arduino
PIR sensor:
- vcc to 5V on Arduino
- gnd to gnd on Arduino
- out to digital pin 7 on Arduino
Code:
First part of the code is defining variables for a pins and notes for a buzzer. Notes are taken from this instructable by eserra. I'm not gona copy note defintions here, you can check them a linked instructable or in a complete sketch file at the end of this step.
#include<Servo.h>
Servo servo;
Servo servo2;
#define buzzer 8
#define pirPin 7</p><p>int okLed = 10;</p><p>boolean lockLow = true;
boolean takeLowTime;
long unsigned int pause = 5000;
long unsigned int lowIn;
int ledPin[] = {2, 3, 4, 5, 6};
Setup functions defines pin modes, returns servo motors into start position and calibrates PIR sensor.
void setup() {
servo.attach(9);
servo2.attach(11);
servo.write(170); //my start position of servos (so their attachments are horizontal )
servo2.write(170);
pinMode(pirPin, INPUT);
digitalWrite(pirPin, LOW);
for (int i = 0; i < 5; i++) { //go trough every red LED
pinMode(ledPin[i], OUTPUT);
}
pinMode(buzzer, OUTPUT);<br> pinMode(okLed, OUTPUT);
digitalWrite(okLed, LOW);
delay(30000); //callibration time for a PIR sensor
digitalWrite(okLed, HIGH);
}
Loop function checks if PIR detected motion (digitalRead on PIR sensor should return HIGH), If motion is detected it starts motionAction function. Full algorythm explanation for working with PIR sensor can be found here so I will not explain it here.
void loop() {
delay(50);
if (digitalRead(pirPin) == HIGH) {
if (lockLow) {
lockLow = false;
motionAction();
delay(50);
}
takeLowTime = true;
}
if (digitalRead(pirPin) == LOW) {</p><p> if (takeLowTime) {
lowIn = millis();
takeLowTime = false;
}
if (!lockLow && millis() - lowIn > pause) {
lockLow = true;
delay(50);
}
}
}
motionAction function turns all red LEDs on, moves servo motors in 90 degrees and starts playing melody. After that it returns motors into starting position and starts playing the same melody again but in a lower octave. It repeats those actions five times.
int motionAction () {<br> for (int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++) {
digitalWrite(ledPin[i], HIGH);
}
servo.write(80);
servo2.write(80);
tone(buzzer, Db6, E);
delay(E + 1);
tone(buzzer, Gb5, E);
delay(E + 1);
tone(buzzer, Gb5, E);
delay(E + 1);
tone(buzzer, Db6, E);
delay(E + 1);
tone(buzzer, Gb5, E);
delay(E + 1);
tone(buzzer, Gb5, E);
delay(E + 1);
tone(buzzer, D6, Q);
delay(Q + 1);
delay(1000);
servo.write(170);
servo2.write(170);
tone(buzzer, Db5, E);
delay(E + 1);
tone(buzzer, Gb4, E);
delay(E + 1);
tone(buzzer, Gb4, E);
delay(E + 1);
tone(buzzer, Db5, E);
delay(E + 1);
tone(buzzer, Gb4, E);
delay(E + 1);
tone(buzzer, Gb4, E);
delay(E + 1);
tone(buzzer, D5, Q);
delay(Q + 1);
for (int i = 0; i < 5; i++) {
digitalWrite(ledPin[i], LOW);
}
delay(1000);
}
}
Downloads
Making Scary Bats
Materials:
- Egg carton
- Tempera
- Thread
Tools:
- Scissors
- Brush
Cut the egg carton and paint each part with black tempera. Leave it to dry for a half an hour. Afterwards you can draw eyes with white tempera. When everything is dried up you can hang it onto a piece of a thread.
Making Scary Ghosts
Materials:
- White sparkling fabric
- Rice
- Solid metal wire
- Black marker
Tools:
- Scissors
Depending on a size of a ghost you should cut the fabric in a square shape. Rice should be put in the middle of a cut fabric. Close the fabric in a way that one part is filled with rice and other is not. Secure structure with a wire. Part with rice in it is a head. You can use marker to paint eyes and mouth on it.
Making Scary Little Halloween Pumpkins
Materials:
- Decorative little pumpkins
Tools:
- Black marker
To make you Halloween scene even better you can buy and decorate little pumpkins with all kinds of drawings.