My son just turned 4, and he is super-excited about Halloween and zombies. So I planned to create a haunted house-like experience for him. The biggest challenge was to get audio-visual effects. I wanted spooky music synchronized with well-placed lighting.
Instead of buying some expensive Halloween decorations, I wanted to build them myself. I also wanted to be able to control the lights over the network. I looked around and didn’t find the perfect solution, so I did what DIY people do best: I picked and chose different pieces to create what I needed.
In this tutorial, I am going to share how you can build a board with Raspberry Pi and open source software that synchronizes music with lights for less than $20. You can place this board inside a plastic pumpkin decoration, for example, or attach LEDs to props and create spooky displays for Halloween. Be creative!
Here is what you need:
A Raspberry Pi 3 (v3 comes with WiFi and Bluetooth)
32 GB Micro SD card (minimum 16GB)
A PC monitor with HDMI port for initial setup
Keyboard and mouse (I recommend Logitech Wireless Touch Keyboard K400 with built-in Multi-Touch Touchpad)
5v 2A power supply (If you want full mobility then get a 5V battery bank for smartphones)
LEDs (minimum of eight, or more as desired)
220 Ohm resistors (one per LED, minimum of eight)
Speakers (get portable Logitech speakers)
Assembled Pi Cobbler Plus - Breakout Cable for Raspberry Pi A+ / B+ (I recommend this one from Adafruit as it has clear pin numbers)
Breadboard and wires (and a basic knowledge of how to use it)
Solderable breadboard (optional)
SoftwareWe will be using linux-based Raspbian as the base operating system for this project. The easiest way to install Raspbian on your Pi is by using NOOBs. Plug in your Micro SD card to your PC and format it as FAT32 using Gnome Disk Utility (Figure 1).
halloween-f1.png
Figure 1: Format Micro SD.
Creative Commons Attribution
Then, change directory to the Micro SD card:
cd /path_of_USBAnd unzip the NOOBS file into the Micro SD card:
unzip PATH_OF_NOOBSIn my case it was:
unzip /home/swapnil/Downloads/NOOBS_v1_9_2.zipEnsure that all the content of the NOOBS folder is in the root directory of the Micro SD card.
ls /path_of_micro_SD_card/You should see all these files there (Figure 2):
halloween-f2.png
Figure 2: Files in root directory.
Creative Commons Attribution
Prepare your PiConnect the Pi to the monitor using an HDMI cable and then connect the keyboard. Connect one end of the GPIO 40 Pin cable to the Pi and the other end to the breadboard using Adafruit Assembled Pi T-Cobbler Plus - GPIO Breakout board. Now plug in the Micro SD card and connect the power supply.
When NOOBS boots, you will see the option to connect to the wireless network. Because we will be using the Rasp Pi outside as a Halloween decoration, we need it to be wireless. Click on the wireless option and select the desired wireless network from the list (Figure 3).
halloween-f3.png
Figure 3: Select wireless network.
Creative Commons Attribution
NOOBS will offer several operating systems to choose from, select Raspbian and let the installation finish. Once the installation is finished, reboot the system. Once you boot into Raspbian, update your system:
sudo apt-get update sudo apt-get dist-upgradeIn order to use the sound output from the 3.5mm jack of Raspberry Pi, run the following command to open the configuration file of Raspbian:
sudo raspi-configThen, go to Advanced>Audio and set audio out from 3.5mm jack (Figures 4 and 5).
halloween-f4.png
Figure 4: Set audio out.
Creative Commons Attribution
halloween-f5.png
Figure 5: Select auto.
Creative Commons Attribution
Install lightshow softwareWe are using the open source Lightshowpi project to control music and lights. Clone the project on your local machine:
git clone https://togiles@bitbucket.org/togiles/lightshowpi.gitChange directory to the newly created ‘/home/pi/lightshowpi’ folder:
cd lightshowpiGrab the stable branch:
git fetch && git checkout stableInstall lightshowpi:
sudo ./install.sh Reboot the system: sudo reboot Install LEDs on the BreadboardWe need to set up the LED lights on the breadboard for initial testing. Now we need to find the right PIN of GPIO board for LED connections. I strongly recommend Adafruit’s Assembled Pi Cobbler Plus - Breakout Cable for Raspberry Pi. This cable comes with clearly marked PIN numbers, which will make it easier to connect to each corresponding PIN. Because we are using 8 LEDs for our setup, let’s find out which PINs are we going to use. Figure 6 shows a picture of the Adafruit’s breakout cable.
halloween-f6.png
Figure 6: Adafruit’s breakout cable.