Introduction: Raspberry Pi Motion Activated Transparent Screaming Ghost for Halloween

Greetings. Please bear with me as this is my first Instructable. However, I have built this effect for this last Halloween and have had some pretty good results with it. So I thought I'd share.

Videos and pics of my test setup for this effect, as well as my entire Halloween setup for 2014 are at the following link: https://goo.gl/photos/aEG3HtFUVeJmWEsz9

UPDATE: This is also the project that was mentioned in the October 2015 issue of Popular Science (page 67).

Introduction

The video above demonstrates the effect. The basic setup uses a projector, a PIR motion detector, raspberry pi, and a piece of plexiglass with a thin spray coating of reflective paint. A loud, startling transparent image appears when a person walks in front of it. I will go over the steps and shell script code used in creating this effect.

The following steps will outline the creation of each of the components of the effect and some possible alternatives.

Step 1: The Transparent Screen

Materials

Plexiglass or Lexan (as large as you need). May be purchased at a place like Home Depot or Lowes.

Reflective spray paint (such as Reflect-All, Rust-Oleum 214944 Reflective Finish, or Night Brite). These are a little harder to find in most of the brick and mortar stores and you may have to go online. Alternatively, you can try a very thin/sparse coat of glass frosting spray paint, which is easier to find.

Wood pieces for frame. I happened to have some left over baluster pieces from a deck project.

Build

Screen - Lay the clear screen down on a tarp and spray a very thin layer of paint over one side of the screen. You do not need much paint at all. I essentially tried to mist on the paint from a good height in order to get a nice sparse, relatively uniform layer. Try practicing first on some cardboard or scrap pieces to get the technique down before spraying onto the screen. Ideally, your screen should remain transparent and nearly clear.

Frame - A large piece of plexiglass is likely too floppy to stand well without a support frame. Lexan (polycarbonate) is stiffer but may be more brittle (and is typically more expensive). You can either build a standing frame or hang the screen from an overhead support. I had to build a standing frame, since I was using this effect outdoors.

I bolted together some leftover deck rail balusters that I had laying around, as shown in the picture above. The screen is sandwiched between pairs of supports at the bottom and side(s) and tightened with bolts drilled through the support pairs. The support legs at the bottom are also drilled and bolted to one of the bottom supports, as shown. Right angle brackets have been screwed into the side and bottom supports.

Alternatives

Theatrical scrim - or any type of thin semitransparent gauzy material hung from a doorway or other support. In the right light (ie. backlight), this should be pretty transparent from the front but still act as a good medium to project a ghost onto. This is used to good effect in this YouTube video. More detailed video instructions are here.

TransScreen - Used in movies and advertising. This is the type of screen my project is trying to simulate at a much cheaper price.

Fog Screen - If you are really ambitious, this is a great effects screen and several people have posted their own builds:

Step 2: The Raspberry Pi

Materials

For this project, I used a Raspberry Pi Model B with a PiFace module. However, you can use any Pi for this project.

The PiFace Module- is optional, since you can interface to the GPIO pins directly or create your own breakout board easily. The PiFace is simply an add-on board for the Pi which gives it some interactive features including separate input/output ports with screwblocks, 4 pushbuttons and 2 relays. I'm not sure how well the current PiFace fits on top of the newer Pi Model B+, although this table seems to indicate that it should still work.

(EDIT) For those of you that have been asking me how to create this effect without the PiFace board, please read me outline in the Comments section below.

The Raspberry Pi - is basically any RasPi running Raspbian or other flavor of linux. Access to the GPIO pins is via the WiringPi library, with instructions for downloading and installing found here. The main code used for this effect is simply a bash shell script which uses the the command-line gpioutility the control to access the GPIO pins on the pi.

The pi should also be configured to output its sound through the 3.5 mm jack rather than the HDMI interface.

The source videos are played by omxplayer on the RasPi and should be encoded into a format compatible with this player.

Step 3: Ancillary Components

Materials

Video Projector - Needs a high brightness (lumens) level for projecting onto a semitransparent screen. An HDMI interface is the easiest way to connect this to the RasPi. Otherwise you will also need an HDMI to DVI convertor cable.

Tripod - Optional but helpful in aligning the projector.

Passive IR motion sensor - Necessary for motion triggering of the effect. These can be purchased from Radio Shack for about $10, or you might find some cheaper on-line.

Powered speaker - Can be wired or wireless. Power can be via batteries or power supply. For best effect this should be hidden but as close as possible to your projection screen. This should also be as loud as possible to add to the "startle factor" when the screaming ghost effect is activated. In the next section (Cabling), I'll discuss how to get sound and power to your speaker over the distance between the RasPi / projector and the screen / speaker.

Source Video - I used the Ghostly ApparitionsDVD from AtmosFearFX, which contains numerous ghost effects for projecting onto a window or wall. This can be purchased on-line, although the Spirit pop-up stores, which appear around Halloween, did actually sell these videos this year. However, you can pick an alternative source for your videos.

The Ghostly Apparitions DVD includes ghost effects which are shown sideways for projecting apparitions in portrait (rather than landscape) orientation, with the projector oriented sideways. This is the way I had set up my own effect.

However, a DVD is insufficient to create an effect which is motion activated. Therefore, I needed to convert the videos I needed into digital format which could be played by omxplayer on the RasPi. I recently noticed that the company has started offering individual digital downloads of their video effects. In my case, I started with the DVD as the original source and used one of the free DVD ripping programs to extract MP4 versions of the specific videos I needed. For the "startle" videos I also had to edit out a second or two of blank space at the start of some of the videos to make them start up more suddenly on motion activation.

Step 4: Cabling

The Cabling

The main issue with this effect effect are that the projector and screen have to separated by a distance. The PIR motion sensor and speaker have to be close to the semitransparent screen and the RasPi has to be close to the projector (unless you have a really long HDMI cable, which can be expensive). So you need several long wires to carry signals back and forth from the pi to the screen. These include:

  • PIR sensor - Three wires (VCC, Trigger and Ground)
  • Audio signal - Mono audio (two wires) or stereo audio (three wires). Optional if you are using a wireless speaker.
  • Speaker power - Two wires, depending on how you are powering your speaker. Optional of you are using battery powered speakers.

So, depending upon your setup, you need between three and eight long wires to communicate between the two ends of the effect. In my case, realized that a Cat 5 or Cat 6 network cable could carry all these signals over a good distance. Rather than cut up a perfectly good network cable, I created my own RJ45 jacks at the RasPi and screen/IR sensor ends of the setup. So long as you keep a consistent color scheme between the two ends, you should be able to connect the two ends with a normal cat 5 or cat 6 cable.

My own wire color scheme, as shown in the pictures above, was as follows:

  • Orange/white - PIR sensor trigger - Connects to PiFace input port 7.
  • Orange - PIR sensor VCC (3-5 volts) - Connects to PiFace +5V
  • Green/white - Speaker power (In the picture above I am sending some of the 5 volt PiFace power to a microUSB jack.)
  • Green - Speaker ground
  • Blue/white - Audio right - Connected to a 3.5 mm audio jack which plugs into the analog audio output of the RasPi.
  • Blue - Audio left - Connected to the 3.5 mm audio jack
  • Brown/white - PIR Sensor ground - Connects to PiFace Ground
  • Brown - Audio ground - Connected to the 3.5 mm audio jack

At the screen end on the effect, I soldered the three PIR wires to a three pin header, which I could use to connect to the sensor with a three-conductor cable. The three audio lines are soldered onto a 3.5 mm audio jack, which can be plugged into the AUX input of the powered speaker. The external power lines are soldered to a 2-pin screw terminal block. In the picture above, the 5 volt power wires of a microUSB connector are also screwed into the screw terminals.

Cautions

Check your connections. Miswiring with live voltages can potentially fry your electronics. Check for shorts and continuity with a multimeter.

Be careful about how much voltage and current you put over the speaker power wires. Cat 5 wire is typically 24-26 gauge (AWG) and cat 6 is typically 22-24 guage. These can typically carry up to 12 volts over long distances (as in power over ethernet applications), However, be careful about sending big voltages/currents over these lines. You probably don't want to directly power a 50 Watt speaker over this line.

Do not confuse this cable with any real network cable that might be connected to your RasPi. We are simply using the cat 5/6 cable as 8-conductor wire which plugs into your home-made jacks at the proximal and distal ends of your ghost effect.

Step 5: Code

I won't go into the details about Raspbian Linux commands or writing executable shell scripts in this document. There is plenty of information out there about it. Just remember to change the mode of the final script to make it executable with the chmod a+x command when you are done editing it.

When I extracted the video video files, they were named after the corresponding track number from the source DVD with a .mp4 extension. On the pi running Raspbian, the extracted and edited videos were transferred to a subdirectory called Video under the default user (username pi).

I wrote a simple bash shell script which uses the gpio command from the WiringPi library to continuously read the GPIO pin connected to the PIR sensor and to read the 4 tactile buttons on the PiFace board. The executable shell script is named scareme and is located in the home directory for user pi.

Notes

The library and gpio utility do support the PiFace addon board. You access the PiFace GPIO pins by adding 200 to the pin number. The script also utilizes the Piface's four tactile input buttons (i/o pins 200 to 203). The code defines the input buttons as follows:

  • 200 - Manual trigger
  • 201 - Volume up
  • 202 - Volume down
  • 203 - Switch video set. The button switches between 3 different sets of videos which can be used for the effect (not scary, scary, and extra long)

In the script, the tactile buttons are initially set up to use the board's built-in pull-up resistors. Therefore, reading the input value for the button is always 1 until someone presses a button and switches it to 0. (Hence, the inverted logic for reading these pins).

scareme script

#!/bin/bash 
# Detect motion on PiFace and play scary video.

# Define PiFace Pins
MotionPin=207 
TriggerPin=200 
VolUpPin=201 
VolDownPin=202 
ModePin=203

Volume=1500
Volstep=50 
CurrentState=0 
CurrentMode=0

DoFlip="" 
# If you need to flip the video upside down, uncomment the following line
# DoFlip="--orientation 180" 

# Assign numbered videos to one of three video modes. Also define the order in which the videos appear
VidMode=0 # 0=Not Scary, 1=Scary, 2=Extra Long 
VidOrder[0]="14 30 46 62" 
VidOrder[1]="12 32 44 64 16 28 48 60" 
VidOrder[2]="6 22 38 54" 
PriorVid=$VidMode 

# Use piface internal pullup resistors on tactile button pins 
gpio -p mode $TriggerPin up 
gpio -p mode $VolUpPin up 
gpio -p mode $VolDownPin up 
gpio -p mode $ModePin up 

# Main Program Loop 
clear
while : ; do 
  for i in ${VidOrder[$VidMode]}; do 
    if [ $VidMode -ne $PriorVid ] ; then echo -ne "Video Set $VidMode\r" ; PriorVid=$VidMode; break ; fi 
    while : ; do 
      PriorState=$CurrentState 
      PriorVolume=$Volume 
      PriorMode=$CurrentMode 
      let "CurrentState=(! `gpio -p read $TriggerPin`) | (`gpio -p read $MotionPin`)" 
      let "Volume += ( (! `gpio -p read $VolUpPin`) - (! `gpio -p read $VolDownPin`) )* $Volstep" 
      let "CurrentMode=(! `gpio -p read $ModePin`)" 
      if [ $Volume -ne $PriorVolume ] ; then echo -ne "$Volume\r" ; fi 
      if [ $CurrentMode -gt $PriorMode ] ; then let "VidMode = ($VidMode + 1) % 3"; break ; fi 
      if [ $CurrentState -gt $PriorState ] ; then 
        omxplayer -b --vol $Volume $DoFlip ./Video/$i.mp4 >> /dev/null 
        clear 
        break 
      fi 
    done 
  done
done

Step 6: Putting It All Together

Hardware Setup

The projector is mounted sideways on the tripod to match the orientation of the screen. Aim the projector at the screen. It is best to aim the projector at an angle with relation to the screen so that the projector light doesn't hit the viewer right in the face when they are in front of the screen.

Connecting the speaker: Either plug in the 3.5 mm jacks to the audio output of your pi and AUX input of your speaker or use a wireless speaker. Make the speaker as loud as possible to add to the "startle" factor.

Run Software

  1. Connect your pi to a USB keyboard and to the the projector via the HDMI
  2. Boot the pi
  3. Enter single-user mode by hitting CTRL+ALT+F1. This keeps the background black while the script is running.
  4. Login as pi with default password raspberry
  5. Run the shell script by typing ./scareme
  6. The program will continue to run until you hit CTRL+C a few times.

Adjustments

I used the manual trigger (tactile button 1) on the PiFace board to manually activate the video at the pi end and make adjustments to the projector. You can also use the buttons to make adjustments to the output volume and to change which set of videos is triggered.

If the motion sensor triggers too soon, you can put a piece of tape over the edges of the sensor to make it less sensitive. The picture shown above shows pieces of tape restricting the sensor view so that it triggers only when someone walks directly in front of the sensor,

In my case I had initially mounted the PIR motion detector onto the frame of the transparent screen, which worked great indoors. However outdoors, the wind caused the frame to move and prematurely trigger the motion detector. So, I moved the sensor to an adjacent, less mobile structure.

Comments

author
Ben Finio (author)2014-11-14

That is REALLY cool. It's amazing how you seemed to get just the right amount of paint for the projection to be highly visible while the glass still seems pretty transparent. Great first time Instructable - you should enter it in the First Time Authors contest if you haven't already.

author
GWPoulos (author)Ben Finio2014-11-15

Thanks. I took your advice and entered the contest.

author
amansinghaljpr (author)2014-11-15

really bro nice use of projection and raspberry pi... i really got scared

author
hdfilmsitesi (author)2014-11-15

oww very nice

author
thasanseelan (author)2014-11-14

woe WO WO WO that is scary

author
Ayush Sharma (author)2014-11-14

OMG ! This is so Cool and Scary! I would have made it if i would have an projector.

it is best for pranks! my friends would just be screaming! and ( i think it could be made on an glass with 2 way privacy film, with a LCD at Behind?)

author
Fission Chips (author)2014-11-14

This is so cool and spooky! Even when I was just watching the vid, I jumped out of my skin. Nice work, and congratulations on the feature!

author
Honus (author)2014-11-14

That is freaking cool!

author
nitishdash2010 (author)2014-11-14

Great one man...... Transparency is a must for total spookiness! Great work.

author
seamster (author)2014-11-14

This is a great effect! That would totally freak me out. Nice work!

author
GWPoulos (author)2015-10-27

Hello, the following is a response to the question I have received "I don't have a PiFace, can you please kindly show me the workaround?". My response is bellow:

You would access the Pi's GPIO (General Purpose i/o) pins directly or use jumper wires to connect the pi to a protoboard. A brief tutorial about using the GPIO pins is here:

https://learn.adafruit.com/adafruits-raspberry-pi-...

To simplify things you only have to connect the three wires of the PIR to the GPIO pins as follows:

PIR sensor trigger -> GPIO 7 pin on the Pi

PIR sensor VCC -> +3.3V pin (we are using 3.3v power ONLY and the sensor should be set to use 3.3v logic, NOT 5v)

PIR sensor Ground -> GND pin

If you want to add a manual button trigger connect the button, then you connect the button between GPIO 0 and GND. A mode change button connects GPIO 3 to ground.

The appropriate changes to the shell script are:

# Define PiFace Pins

MotionPin=7

TriggerPin=0

ModePin=3

Please note that it doesn't matter which particular pin numbers you use, so long as you are consistent in the script code. Also please note that there are different numbering systems for the GPIO numbers on a Pi, the script accesses the pins using the "gpio" command, which uses the Wiring Pi numbering of the pins:

http://wiringpi.com/ and http://wiringpi.com/

I will also post this message to the general comments under my project to help anyone else with this question.

author
GWPoulos (author)GWPoulos2015-12-04

After looking at the specs for the various PIR motion sensors, almost all of them require +5v on VCC, but many output +3.3v on the output. Some give you a choice to output +5v or +3.3v, depending on a jumper setting. Therefore, make sure the the VCC pin on the PIR is connected to +5v and make sure that the output voltage of the PIR (which connects to the GPIO pin) is at 3.3v.

author
GWPoulos (author)GWPoulos2015-10-27

I meant to write http://wiringpi.com/pins/ as the second site for the Wiring Pi pin numbering

author
Leatherphace (author)2015-11-01

If you could what is the pin layout you have on the costum connectors?

author
jayanthkumarak (author)2015-02-18

Holy S*** dude. Amazing.

About This Instructable

27,650views

396favorites

License:

Bio: At various points in my life I was an engineer, programmer, biophysicist, and physician. Now I look at people's insides without having to cut ... More »
More by GWPoulos:LED Lighthouse Light - Preliminary WorkRaspberry Pi Motion Activated Transparent Screaming Ghost for Halloween
Add instructable to: