Possessed Screen for Halloween Using PIR Sensor and Arduino!!

by fast_as_cheetah in Living > Halloween

1573 Views, 13 Favorites, 0 Comments

Possessed Screen for Halloween Using PIR Sensor and Arduino!!

23223153_482404342146776_894553561_o.jpg

It's Halloween!!! Time to decorate your house as creepiest as possible!!! Besides the traditional costume, there is technology for you to be creative!!!. This tutorial will show you how to build a possessed screen to surprise your friends passing by.

AtmosFX has some very cool jump-scare video that are only $7.99 each. It is perfect to decorate you possessed house at Halloween.

The components that you will need are:

  1. - Arduino (UNO, Nano, Mega,...) in this tutortial, I use Arduino Nano
  2. - Connecting cable.
  3. - PIR Sensor
  4. - Some female to female wire
  5. - A laptop
  6. - A mean to display (TV screen, Projector,...)

Now, let's do some programming!!

Set Up Your PIR Sensor and Arduino:

23158032_482396378814239_592421950_o.jpg
23158208_482396348814242_140184957_o.jpg
23158373_482396358814241_331693540_o.jpg
23191636_482396398814237_193927688_o.jpg
23192442_482396338814243_1981337382_o.jpg
23224536_482396315480912_1533317236_o.jpg
pir.png

Now let's begin with the wiring.

The PIR sensor has 3 pins. From left to right:

- VCC: connect to 5V pin of the Arduino - OUT: the pin to collect data, connect to 12 pin of the Arduino. - GND: connect to GND pin of the Arduino.

Connect the cable from your Arduino to your laptop.

Upload the Code to Your Arduino:

upload.png

With your Arduino connected to your laptop, now open Arduino IDE. It can be install here.

Copy this code to your .Arduino IDE:

void setup() {<br>  Serial.begin(9600);                                       //Begin the Serial communication with your computer
}
void loop() {
  if(digitalRead(12) == HIGH){                         //To check if the PIR sensor detects your friends
    Serial.println(1);                                          //Send 1 to your laptop, mean there are some person passing by
  }
  else Serial.println(0);                                   // If there aren't anyone, send 0
  delay(60000);                                              // Some free time after sending data to avoid continually playing the video
}

Now click "Upload" to transfer your code to the arduino.

Downloads

Set Up Your Python Program!

arduino.png
python.png

In this tutorial, I use python 3.5.2 32 bit.

There a library you need to install to use the code.

Open your Command Prompt and type:

pip install pyserial

and press Enter. Wait for the library to be downloaded.

Now open Python IDLE.

import serial, time<br>
#TWO CLASSES BELOW IS TO DISPLAY VIDEO
class Video(object):
    def __init__(self,path):
        self.path = path
    def play(self):
        from os import startfile
        startfile(self.path)
class Movie_MP4(Video):
    type = "MP4"
#THE MAIN CODE:
count = 0
arduino = serial.Serial('COM5', 9600, timeout=.1)	       #SET UP YOUR CONNECTION TO THE ARDUINO.
time.sleep(1) #give the connection a second to settle	       #YOU SHOULD REPLACE "COM5" WITH YOUR COM 
movie = Movie_MP4(r"C:\Users\admin\Desktop\scare\scare.mp4")   #YOU SHOULD WRITE YOUR OWN DIRECTORY TO THE VIDEO HERE
while True:
        data = arduino.readline()		#READ DATA FROM ARDUINO
        print(data)
        if (data == b'1\r\n'):			
                movie.play()			

Copy and paste the code above, or download mine.

My Arduino is connected at COM5.

At the python window, press F5 to run the script.

Downloads

Display Your Spooky Video!!

Halloween prank

Now the last step is to connect your laptop into a TV screen, a projector or whatever mean of display you have. I don't have one right now so I'll use my laptop screen instead.

When a friends passing by, the PIR will detect that there are people. It will trigger the arduino to send data to the python script, that will open the Video.

It's all done now and it's time to have some fun with your friends.

Happy Halloween!!