The Pumpkin Project: Part Two

Today we have the build pictures and code. There will be a final post covering the final set up on Halloween so keep an eye out for that. It will include video of the final setup.

The Hardware:
1 - PIR sensor -
1 - 15ft phone wire -from Wal-mart
6 - LED flicker candles - from Target
5 - red flicker LEDs -
10 - 220Ω resistors - from that compartment in my tool box
6 - Some random proto boards - and
1 - Arduino Uno
1 - Raspberry Pi
1 - Powered Speakers - had some laying around
1 - Wireless card - had 3 laying around

The Build:
The first step was taking apart some cheap flicker led candles and clearing out space inside. After the led is removed the post holding the led can be removed from inside and the plastic guide for the power switch can be removed too. You will also want to remove the contacts from the battery housing and look free CR2032s. The last prep step is to drill a hole for the second led and the wire.

The PIR sensor is just a standard pir from adafruit. I connected the jst cables to some phone line and run that back to the arduino. To get it mounted I cut a pass through for the connector where I wanted the sensor and used toothpicks through the mounting holes to hold it in place.

Now for the assembly. Each candle will need one yellow and one red flicker led and some 220Ω resistors. The diagram will look something like what is seen in the diagram. You have a resistor to vcc a resistor to ground the diodes connected in series and the pin connection for the arduino between the LEDs. The way this circuit works is when the pin is high no voltage can pass through the yellow diode since the diode is being reverse biased. When the pin goes low the red diode will be reverse biased.

For this project I decided to use phone line since it would keep my wires nicely bound and give me the 3 leads I needed. To keep things clean I just cut back the fourth wire. For the arduino side I built a harness for the lights. The main board has a ground and 5v bus and connector pins for providing ground and 5v to the harness as well as a pin for the PIR sensor input.

The Code:
On the arduino side we have code that will pass a value over serial when the pir sensor is triggered. The value is random and will tell the pi what dialog chain to run through. It will also wait for a clear signal from the pi before starting a new chain. During a chain the uno will parse a 5 character string to determine which pumpkins should be talking. The code can be seen below and on github at:

For the pi the code will play a dialog chain based on what the arduino says. When it strarts a chain it will tell the uno what pumpkin to light and will play an audio file. When the audio is done it will tell the uno to light the next pumpkin in the chain. When the chain is complete it will then wait 20 seconds before sending an all clear to the arduino starting the process over. The code can be seen below and is on github at:

I have also included the audio files for the project on the github repository. If you have questions about the audio files they are pitch tempo and level shifted to some degree or another.


Popular posts from this blog

The Pumpkin Project: Part One

ESP-01 Programmer for ESP8266