Raspberry Pi-powered ghosts will haunt your house on Halloween

Learn how to create a fully automated ghost show that you can project on any screen — or the walls of your house.

I have been busy playing with Raspberry Pi, Arduino board and electronics lately. I have been building projects for Halloween as my 4 year old son is super excited about it. We created a graveyard scene in our back patio and installed a projection system that runs a spooky projection show featuring ghosts and spirits hanging out in the graveyard. This project is about building a fully automated projection system using Raspberry Pi, Linux and open source scripts. I purchased special effects videos from AtmosFX, but you can create your own spooky videos. 

What you need:

Install Raspbian on Raspberry pi

First we need to install Raspbian (a Linux based operating system) on our Raspberry Pi. The easiest way is through NOOBS. Download NOOBS from the official site. I am assuming you are either using Linux or macOS because these two platforms come with the Terminal app that allows users to perform many tasks from the command line. If you are a Windows user, then you can use Putty to manage your Pi remotely.

Plug in your microSD card to your PC and format it as FAT32. Unzip the content of the downloaded NOOBS file and then copy them to the microSD card. Make sure that you have copied the content of the NOOBS directory to the microSD card. When you open the microSD card, you should see all files as seen below:

noobs Swapnil Bhartiya

Content of the NOOBS folder

Insert the microSD card into the Raspberry Pi, connect the monitor through the HDMI cable, connect keyboard & mouse and plug in the 5v power supply. The Pi will boot into NOOBS and you will see this image.

noobs 1 Swapnil Bhartiya

I recommend connecting to the Wifi so that you get updates images. Once connected, it will show the latest operating systems for the Pi; choose Raspbian on the top and let NOOBS install it for you. It may take a while. Once Raspbian is installed reboot your system:

sudo reboot

(Note: The password for pi is ‘raspberry’).

Once you boot into Raspbian, first connect to the Wireless network using the Wireless option on the top bar. Now find the IP address of your system as we will be doing the rest of the installation and configuration remotely. Run the following command in the terminal:


Note down the IP address showed in the ‘wlan0’ section.

ip address Swapnil Bhartiya

Note down the IP address showed in the ‘wlan’ section.

In my case it was Once you have the IP address, open the terminal app on your macOS or Linux system (if you are on Windows, you can use Putty). Then ssh into the Pi:

ssh pi@

When asked, enter the password for pi that is ‘raspberry’. Now you can control and manage your Pi, remotely from any PC in the local network. If you want, you can unplug the keyboard; just leave the monitor attached as we need to verify that video playback is working OK.

Let’s first update Raspbian:

sudo aptitude update

sudo aptitude dist-upgrade

(Important Note: From now onwards, all of these commands are being run from a remote machine using the ssh protocol)

Automate the video playback

Since we are going to create a projection show, I wanted to automate things as much as possible. My desired solution was that the horror show will start as soon as the Raspberry Pi boots up; I didn’t want to open the file and play it in a media player. I found a great open source script called Video Looper. It plays selected videos in fullscreen mode automatically.

First we clone the Video Looper repository from GitHub onto our Raspberry Pi.

git clone https://github.com/adafruit/pi_video_looper.git

We change directory to the video looper folder:

cd pi_video_looper

And then install the script:

sudo ./install.sh

Once the script is installed, you will notice that the monitor hooked to the Pi goes blank and a message to insert USB drive is displayed. Which means our script installed properly.

We now have to make some changes to the Video Looper scrip. By default Video Looper needs a USB flash drive plugged to the Pi in order to play videos; we are going to change that. We will edit the ‘video_looper.ini’ file to make desired changes. Open the file in the terminal with preferred editor:

cd /boot

sudo nano  video_looper.ini

Scroll down in the file and find the section where it says:

file_reader = usb_drive

#file_reader = directory

Since we are not going to use USB, comment the first line and uncomment the second line, so it becomes like this:

#file_reader = usb_drive

file_reader = directory

Then we are going to disable the information that’s displayed before videos are played. Find these lines :

osd = true

#osd = false

Then disable osd (on screen display) so it will look like this:

#osd = true

osd = false 

We now need to provide Video Looper with the path of the folder where videos will be stored for playback. Find this line and add the path to the ‘Videos’ folder so it looks like this:

# The path to search for movies when using the directory file reader.

path = /home/pi/Videos/

Now we have to copy our spooky videos to the ‘Videos’ directory.  It can play a few video formats including .mp4 and I heavily recommend using mp4 format. Just copy the desired video files to the Videos directory of the Pi. You can either plug in a USB drive with videos on it and copy them to the Videos directory or use the ‘rsync’ command on Linux and macOS systems to copy files from the local machine to the Pi over wireless.

I use the rsync command as it’s much easier. I saved the mp4 files that I wanted to copy to the Pi in the ‘movies’ folder inside theHome directory of my Fedora system. The following command copied all mp4 files inside the movies folder of my local machine to the Videos directory of the Pi.

rsync –avzP /path_of_mp4_files.mp4 pi@ip_address_of_pi:/home/pi/Videos/


rsync –avzP /home/swapnil/movies/ pi@

If you want, you can reboot your Pi to check if the videos are playing automatically.

Add a shutdown button to the Pi

We need to make one final adjustment to our project before we install our system outdoors for the show. Raspberry Pi doesn’t come with any physical button that allows us to easily shut it down properly. Since we will be installing our projector set-up outside I wanted anyone in my family to be able turn it on and off. You can’t just unplug the power cable from the Pi as it will corrupt the sd card. We are going to use a simple script written by Inderpreet Singh to add a shutdown button to our Pi.

First we need to configure a GPIO pin of Raspberry Pi that can be used to trigger the shutdown command. SSH into your Pi and create a folder called ‘Scripts:

mkdir Scripts

Now cd to this folder:

cd Scripts

Then create a file with nano editor:

nano stop_pi.py

Copy the following code into that file


# Simple script for shutting down the raspberry Pi at the press of a button. 

# by Inderpreet Singh 

import RPi.GPIO as GPIO 

import time 

import os  

# Use the Broadcom SOC Pin numbers 

# Setup the Pin with Internal pullups enabled and PIN in reading mode. 


GPIO.setup(21, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

# Our function on what to do when the button is pressed 

def Shutdown(channel): 

   os.system("sudo shutdown -h now") 

# Add our function to execute when the button pressed event happens 

GPIO.add_event_detect(21, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)  

# Now wait! 

while 1: 


Save and close the file. (In nano you use Ctrl+x and then type y to save the file.)

Here we are using the GPIO pin #21 as it’s next to the ground pin and I don’t use this pin in my other projects, including the Spooky Halloween music and light show. Now we need to set this script to run as root:

sudo python stop_pi.py

Use two jumper cables and plug into the pin #21 and GND. Then connect these wires to a push button.

switch Swapnil Bhartiya

Adding a shutdown switch to Pi.

Now you can try to push the button to verify that the system will shut down. If it works, reboot the system and log into the system via ssh again as we still have some work to do. First of all we need to make sure that the script runs at system boot.

Edit the ‘rc.local file to add the command that starts our shutdown python script, 'sudo python /home/pi/Scripts/stop_pi.py &'.

sudo nano /etc/rc.local

Now add the command for stop script before the ‘exit 0’ line, so it will look like this:

# Print the IP address

_IP=$(hostname -I) || true

if [ "$_IP" ]; then

 printf "My IP address is %s\n" "$_IP"


sudo python /home/pi/Scripts/stop_pi.py & 

exit 0

That’s all. Our setup is fully automated. Now plug in the projector to the HDMI port of the Pi, connect a speaker and install your setup where you want the projection to happen.

ghosy Swapnil Bhartiya

Here is a ghost floating on our wall at night.

Enjoy your freaky Halloween show and good luck scaring your neighbors.

Related video:

Copyright © 2016 IDG Communications, Inc.

Download CIO's Winter 2021 digital issue: Supercharging IT innovation