top of page

DIY: PIR Motion Activated Music Box

Updated: Jul 19, 2023

In this tutorial, I will demonstrate how to create a Passive Infrared motion-activated music box for ghost hunting or paranormal research using an Arduino Nano. Arduino offers a straightforward and cost-effective solution for prototyping various projects.

Update 7/10/2023: Added an LED to indicate motion.

Most of the components can be purchased from Amazon or

Components Needed

Tools Needed

  • Soldering iron and solder

  • Wires

  • Battery, anywhere between 5v to 9v is okay.

  • An Arduino Nano Expansion Board is nice but not necessary.

Step 1 - Programing the Arduino

  • Program the Arduino Nano

  • Code is available for download. This is offered free of charge, as-is, no warranty.

  • Unzip the file

Download ZIP • 1KB

  1. Connect the Arduino Nano to computer via USB cable.

  2. Start the Arduino IDE program.

  3. Under Tools select the following:

    1. Board: “Arduino Nano”

    2. Processor: “ATmega328P” May need to select “ATmega328P (Old Bootloader)”

    3. Programmer: “Parallel Programmer”

    4. Port will be unique, select correctly.

  4. Under File select Open

    1. Choose the unzipped file.

  5. Program the Arduino Nano

    1. Select Upload or Ctrl+U

Step 2 - Connect the Buzzer and LED

  • Connect the Buzzer and LED

  • Be sure to use an externally driven buzzer.

1. Connect the buzzer positive to pin D3

2. Connect the buzzer ground to GND

3. Connect the LED positive to pin D4 (long leg is positive)

4. Connect the LED ground to GND

Step 3 - Connect the HC-SR501 Sensor

1. Connect sensor output to D2

2. Connect Vcc to Arduino 5v

3. Connect Gnd to Arduino GND

Step 4 - Connect Battery Power

  • You can use any supply from 5v to 9v

  • Disconnect the USB cable

1. Connect the positive end of the battery to Arduino Vcc

2. Connect the ground end of the battery to Arduino GND

Notes About the Code

  • The code will play Twinkle Twinkle Little Star when the PIR sensor detects motion.

  • If you need any modifications to the code but lack the ability to do it yourself, I suggest utilizing to find a skilled Arduino programmer who can assist you.

Step 5 - Enclosure

  • The final step is to put your board into an enclosure.

    • Wooden boxes from craft stores are common.


Attached is the Gerber files for a PCB. This is offered free of charge, as-is, no warranty.

Download ZIP • 715KB

Part Numbers:

  • Buzzer: AT-1224-TWT-5V-2-R

  • PIR Sensor: HC-SR501

502 views0 comments


Rated 0 out of 5 stars.
No ratings yet

Commenting has been turned off.
bottom of page