PIR Halloween Ghost Decoration (Motion-Activated)

Project Overview

Create a fun Halloween decoration that comes to life when trick-or-treaters approach. When the PIR sensor detects motion, the ghost lights up with eerie LEDs, plays spooky sounds, and can even move using a servo motor.

Difficulty: Beginner
Estimated time: 2 hours
Estimated cost: $20-30

How It Works

A PIR sensor detects motion. When triggered, the system activates LEDs (in the ghost’s eyes or body), plays a spooky sound through a speaker, and optionally moves a servo to make the ghost shake or wave. After a few seconds, it returns to standby mode.

Materials Needed

  • Arduino Uno or Nano (1)
  • HC-SR501 PIR sensor (1)
  • DFPlayer Mini MP3 module (1)
  • MicroSD card with spooky sound files
  • Small speaker (3W, 4-8Ω)
  • LEDs (white or color, 2-4)
  • 220Ω resistors (for LEDs)
  • Servo motor (SG90, optional)
  • White fabric (for ghost costume)
  • Wire or PVC pipe (for ghost frame)
  • Jumper wires
  • Power supply (5V 2A or battery pack)

Circuit Diagram

Connection Table

VCC

5V

GND

GND

OUT

Digital Pin 2

TX

Digital Pin 11

RX

Digital Pin 10 (via 1kΩ)

SPK+

Speaker (+)

SPK-

Speaker (-)

Anodes

Digital Pin 9 (via 220Ω)

Signal

Digital Pin 3

Arduino Code

#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
#include <Servo.h>

SoftwareSerial mySoftwareSerial(10, 11);
DFRobotDFPlayerMini myDFPlayer;
Servo ghostServo;

const int pirPin = 2;
const int ledPin = 9;
const int servoPin = 3;

unsigned long lastTriggerTime = 0;
const unsigned long effectDuration = 5000;
bool isActive = false;

const int ghostMoan = 1;
const int spookyLaugh = 2;

void setup() {
  Serial.begin(9600);
  
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  
  ghostServo.attach(servoPin);
  ghostServo.write(90);
  
  mySoftwareSerial.begin(9600);
  if (!myDFPlayer.begin(mySoftwareSerial)) {
    while (true);
  }
  myDFPlayer.volume(25);
  
  delay(60000);
}

void activateGhost() {
  isActive = true;
  lastTriggerTime = millis();
  
  digitalWrite(ledPin, HIGH);
  
  int randomSound = random(1, 3);
  myDFPlayer.play(randomSound);
  
  for (int i = 0; i < 3; i++) {
    ghostServo.write(60);
    delay(150);
    ghostServo.write(120);
    delay(150);
  }
  ghostServo.write(90);
  
  for (int i = 0; i < 3; i++) {
    digitalWrite(ledPin, LOW);
    delay(100);
    digitalWrite(ledPin, HIGH);
    delay(100);
  }
}

void deactivateGhost() {
  isActive = false;
  digitalWrite(ledPin, LOW);
  ghostServo.write(90);
}

void loop() {
  bool motionDetected = digitalRead(pirPin) == HIGH;
  
  if (motionDetected && !isActive) {
    activateGhost();
  }
  
  if (isActive && (millis() - lastTriggerTime > effectDuration)) {
    deactivateGhost();
  }
  
  delay(50);
}

Ghost Construction

Frame

  1. Use wire hanger or PVC pipe to create a frame about 2-3 feet tall
  2. Mount servo motor at the top if using moving ghost
  3. Attach LEDs at eye positions
  4. Position PIR sensor at chest height facing forward

Costume

  1. Drape white fabric (old sheet or cheesecloth) over the frame
  2. Cut eye holes or use transparent material over LEDs
  3. Drape the fabric to create a ghost shape
  4. Secure with tape or wire ties

Installation Steps

  1. Assemble electronics on breadboard and test
  2. Load sound files to microSD card
  3. Build ghost frame and attach servo
  4. Mount PIR, LEDs, and speaker to frame
  5. Drape fabric over frame
  6. Connect battery or USB power
  7. Walk in front to trigger the ghost

Project Extensions

  • Use WS2812B addressable LEDs for color-changing effects
  • Add a small fog machine for an eerie effect
  • Use multiple PIR sensors to track movement across yard
  • Add Bluetooth to trigger ghost from phone
  • Use ESP-NOW to synchronize multiple decorations

Conclusion

This motion-activated ghost is a fun and engaging Halloween decoration that delights trick-or-treaters. With simple materials and basic electronics, you can create a memorable spooky experience.

Leave a Reply

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

Component Pin Arduino Pin
PIR Sensor PIR Sensor PIR Sensor DFPlayer Mini DFPlayer Mini DFPlayer Mini DFPlayer Mini LEDs (parallel) Servo