NederlandsKlik deze knop voor de Nederlandstalige website

Lightning & thunder: Arduino Halloween DIY project

For this year’s Halloween I wanted to do some fun DIY projects with stuff I already had laying around. This project is about simulating the lightning and thunder of a thunderstorm with an Arduino, LEDs and a DFPlayer Mini MP3 player module (see the documentation).  It is easy to build and it worked out really well. So here it is, for anyone who also wants to surprise (or scare) his/her guests next year.

Note that this is not a “sound to light” system. The sketch (randomly) flashes the LEDs first and then plays the sound file after a short (random) delay. I think that’s more realistic than flashing the LEDs in reaction to the volume of the sound like other projects/systems do. Light travels much faster than sound. Therefore, during  a real life thunderstorm, you will usually observe the flashes first. The sound will be delayed, depending on how far away the lightning occurred.

Lightning simulator project: parts list

The parts used for the project:

Of course, you can use some other 12V LED lights.  The MP3 files (see below) are only about 6MB so any SD card will do.

Lightning and thunder Arduino Halloween DIY project: DFPLayer Mini MP3 module
Lightning and thunder Arduino Halloween DIY project: DFPLayer Mini MP3 module

Wiring the Arduino lightning simulator

The wiring is pretty straightforward, see the images below:

  1. The 12V power supply is connected to the red breadboard power rail on the breadboard.
    The LEDs get 12V from the power rail (red wire).
    The Arduino Nano gets 12V power from the power rail to its Vin pin (red wire) and the Nano GND pin is connected to the common ground rail (blue wire).
  2. The DFPlayer Mini gets 5V on its VCC pin from the Nano (red wire).
    The RX pin from the DFPlayer goes to pin 10 on the Nano (black wire) via an 1K resistor.
    The TX pin from the DFPlayer goes to pin 11 on the Nano (purple wire) via an 1K resistor.
    The BUSY pin from the DFPlayer goes to pin 12 on the Nano (white wire).
    The DAC-L (green wire) and DAC-R (yellow wire) go to the stereo audio amplifier.
    The GND pin from the DFPlayer goes to the common ground rail (blue wire).
  3. The MOSFET GATE pin (left) goes to the Nano pin 9 (orange wire).
    The MOSFET DRAIN pin (center) goes to the LEDs ground wire (black wire).
    The MOSFET SOURCE pin (right) goes to the common ground rail (black wire).
  4. The amplifier’s ground is connected to the common ground rail.
Arduino Halloween: thunder and lightning with DFPlayer, breadboard view
Arduino Halloween: thunder and lightning with DFPlayer, breadboard view

Make sure that the power supply, Arduino, MOSFET, DFplayer and audio connection share the same common ground. Also make sure the 12V is connected to the right pin (Vin) on the Nano.

Make sure you have the polarization of 12V and ground of the power supply and the LEDs right.

I used some wires with alligator clips to easily connect the LEDs and audio to the breadboard.

Lightning and thunder-Arduino Halloween DIY project: wiring
Lightning and thunder-Arduino Halloween DIY project: wiring

Lightning and thunder sound files

I have collected 17 different lightning and thunder sound samples in a .zip file. They can be downloaded using the link below. The files (0001.mp3 to 0017.mp3) should be put in a folder called ‘mp3’ on the SD card. The card may be formatted FAT16 or FAT32.

Programming the Arduino

You can upload the sketch to the Arduino the usual way, using the USB cable. The Nano gets its power from the 12V power supply, not from USB. So after uploading you can disconnect the USB cable.

The sketch uses the DFRobotDFPlayerMini library, check out the GitHub page and documentation for details.

DFPlayer Mini MP3 Player Module For Arduino
Tested and recommended by OneGuyOneBlog.com:

DFPlayer Mini MP3 Player Module For Arduino
5M Cool White 3528 SMD LED Strip Light Non-Waterproof 12V DC 300 LED
Tested and recommended by OneGuyOneBlog.com:

5M Cool White 3528 SMD LED Strip Light Non-Waterproof 12V DC 300 LED
10Pcs IRFZ44N Transistor N-Channel Rectifier Power Mosfet
Tested and recommended by OneGuyOneBlog.com:

10Pcs IRFZ44N Transistor N-Channel Rectifier Power Mosfet
65 Pcs Breadboard Jumper Connect Cable Adapter Cable
Tested and recommended by OneGuyOneBlog.com:

65 Pcs Breadboard Jumper Connect Cable Adapter Cable
8G Micro SD TF Micro SD Card For Cell Phone MP3 MP4 Camera
Tested and recommended by OneGuyOneBlog.com:

8G Micro SD TF Micro SD Card For Cell Phone MP3 MP4 Camera
DANIU 42cm 10pcs Alligator Clips Electrical DIY Test Leads
Tested and recommended by OneGuyOneBlog.com:

DANIU 42cm 10pcs Alligator Clips Electrical DIY Test Leads

This post is also available in Dutch.

Add a Comment

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