Arduino Halloween Project 2021

Arduino Halloween Project Blog post image

Creating a Motion Triggered Halloween Prank!

Welcome to the spookiest house on the block, where Halloween meets high-tech trickery! Are you tired of the same old predictable scares for your unsuspecting trick ‘r’ treaters? This year, we’re taking Halloween pranks to the next level by combining the eerie allure of a haunted house with the magic of Arduino and a DFPlayer MP3 module. Get ready to unleash bone-chilling scares and spine-tingling sound effects as trick-or-treaters dare to approach our front door. In this electrifying post, we’ll reveal how to create your very own Halloween Pir Prank that will leave your guests trembling with fear. So, grab your cauldron, dust off your wizard’s hat, and let’s brew up some terror together with this year’s Arduino Halloween Project!

Components for this Project:

  • Arduino
  • MP3 Module
  • SD Card
  • PIR Sensor

Programming PIR Sensor

If you have never used a PIR sensor before you can follow this guide to learn about what the PIR sensor is and how to set it up with Arduino:

Programming the PIR Sensor with Arduino

Programming the DFPlayer MP3 Module

If you haven’t used the DFPlayer MP3 module you can learn the basics here:

Programming the DFPlayer MP3 Module with Arduino

Halloween PIR Prank

The Code:

The code is fairly straight forward, and if you have read the two guides mentioned above you will know exactly what is going on.

//Include Libraries
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10,11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

//Pin To Read PIR Sensor Data
int pirPin = 7;

//Variable To Store PIR Sensor Data
int pirValue;

// Set Duration Sound Effects Will Loop For
int soundLoop = 20000;

// Set Volume Level 0-30
int volLvl = 15;

void setup() {
  Serial.begin(9600);
  mySoftwareSerial.begin(9600);
  myDFPlayer.begin(mySoftwareSerial);
  myDFPlayer.volume(volLvl);
  pinMode(pirPin,INPUT);

  //Add Delay To Stabilize PIR Sensor
  Serial.println("10 Second Wait While Sensor Stabilizes");
  delay(10000);
}

void loop() {
  // Read PIR Pin
  pirValue = digitalRead(pirPin);
  
  // Set Trigger Condition
  if (pirValue == 1){
    Serial.println("Motion Detected");    
    myDFPlayer.enableLoopAll(); // Uncomment to Loop All
    //myDFPlayer.randomAll(); // Uncomment to Randomize   
    delay(soundLoop);           
  }else{
    Serial.println("No Motion");
  }
  myDFPlayer.disableLoopAll();  
  delay(1000);
}
The Circuit:
Halloween PIR Prank Circuit Diagram
Prepare SD Card:

Format your SD Card to the Fat-32 Filesystem. Once SD Card is ready you can add your MP3 sound effects. It is recommended that you label the MP3 tracks with the 0001, 0002, 0003 naming convention, but I have just added mine without doing so and it worked just fine.

Upload the Code:

Once you have the circuit built and the SD Card prepared, go ahead and insert this SD Card and then upload the code. There is a 10 second stabilizing period when you first turn on the device, this helps the PIR sensor get used to the surroundings and reduce false positives.  After 10 seconds wave your hand in front of the sensor to trigger motion, and if all went well the MP3 module should trigger.

If you fail to get a response, double check all connections against the diagram provided. If you are still having problems, then please read our guides on using the MP3 Module and PIR Sensor:

 

Conclusion

This project wasn’t just about scares; it’s about creating lasting memories and fostering the sense of wonder that makes Halloween so special. As you embark on your own journey to spookify your Halloween, remember that innovation and imagination know no bounds. Whether it’s a fiendish sound effect or a ghostly apparition, the only limit is your own creativity.

So, unleash your inner mad scientist, tinker with technology, and let your spooky visions come to life. Halloween is a time for tricks and treats, and with your newfound knowledge, you’re ready to make every Halloween unforgettable. From our eerie abode to yours, have a ghoulishly good time and remember, the only thing to fear is running out of candy!

Happy Halloween, my fellow haunters!”

Recommendations:

The Elegoo Super Starter Kit

If you don’t already own any Arduino hardware, we highly recommend this kit as it has everything you need to start programming with Arduino. You can find out more about this kit, including a list of its components here: Elegoo Super Starter Kit

You can find this kit on Amazon here: Elegoo Super Starter Kit

The 0.96-inch Mini-OLED Display

We highly recommend this mini-OLED bundle of five 0.96-inch OLED displays. We have bought these before and they all worked perfectly. You can read more about the mini-OLED here: Mini-OLED

You can find this bundle on Amazon here: OLED Displays

Elegoo Nano (Arduino Compatible)

We have bought these Nano boards many times and can highly recommend them. There are three Nano boards in this pack making them a total bargain for everyone.

You can find this pack on Amazon here: Arduino Nano

ESP8266 D1-Mini

D1-Mini is an Arduino compatible Wi-Fi board based on an ESP-8266-12F. This WLAN board has 9 digital I/O pins.

You can find this board on Amazon here: D1-Mini

Luke Barber

Hello, fellow tech enthusiasts! I'm Luke, a passionate learner and explorer in the vast realms of technology. Welcome to my digital space where I share the insights and adventures gained from my journey into the fascinating worlds of Arduino, Python, Linux, Ethical Hacking, and beyond. Armed with qualifications including CompTIA A+, Sec+, Cisco CCNA, Unix/Linux and Bash Shell Scripting, JavaScript Application Programming, Python Programming and Ethical Hacking, I thrive in the ever-evolving landscape of coding, computers, and networks. As a tech enthusiast, I'm on a mission to simplify the complexities of technology through my blogs, offering a glimpse into the marvels of Arduino, Python, Linux, and Ethical Hacking techniques. Whether you're a fellow coder or a curious mind, I invite you to join me on this journey of continuous learning and discovery.

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights