Thunder And Lightning Effect Using Arduino And AC Bulb

Thunder And Lightning Effect System: Today we are going to build a cool project that is thunder and lightning effect using Arduino. Lightning is the most spectacular part of a thunderstorm. In fact, it is how thunderstorm got its name. The lightning causes the thunderstorm.

A single stroke of lightning can increase the heat of the air to around 30,000°C that can expand fast in the air. This expansion then creates a shockwave which turns into an explosive sound. That is called thunder.

In this Arduino project, we will be going to build an artificial thunder and lightning effect using Arduino, sound sensor and dfplayer. This project is useful for photography and videography studio to make an artificial lighting effect for shooting effects.

Principle Behind the Thunder And Lightning Effect Using Arduino

This is not just a sound to light effects system. We build this project in two different ways. The first one is done using a sound sensor and the second one is done by dfplayer SD card module.

Let’s talk about the first one. Its working principle is so simple. It is working by sensing the sound beat and sends signals to Arduino. The Arduino then produce an output signal and glow the AC bulb according to rythm.

The second one is a little different. It is not working by sensing sound via a sensor. The dfplayer is used here to produce the signal for glowing the AC bulb. It catches the signal from the SD card sound sample and converts it to a lightning effect.

Must Read Arduino based WS2812B Ambilight for Home Decoration

Thunder And Lightning Effect Using Sound Sensor

Project

Thunder And Lightning Effect Using Sound Sensor

Circuit Diagram

Thunder and lightning effect using a sound sensor circuit

Components Required

  • Arduino Nano
  • Sound Sensor Module
  • 5V Relay Module
  • AC Bulb
  • 9V Battery

Circuit Design Using PCB Software

To make the circuit compact and give a professional look, I have designed the PCB after testing all the features of the thunder and lightning effect using a sound sensor on the breadboard. I will explain in detail how we can design and order PCB for our project.

Thunder and lightning effect using the sound sensor pcb

Gerber file for Thunder and lightning effect using the sound sensor.

Order PCB From PCBWay

This project is sponsored by PCBWay.com. PCBWay is a Chinese-based PCB (printed circuit board) prototype, PCB assembly, SMD Stencil, and Flexible PCB manufacturer. They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. The quality of the PCB is awesome and its thickness is really great. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronic hobbyists In this article, I will state that how can we order PCB from PCBWay with step by step guide.

Features of PCBWay

1. PCB prototyping and manufacturing

They produce FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price.

Visit the link for Instant Quote

Visit the link for Gerber file viewer

2. PCB assembly

SMT & THT assembly starts from only $30 with a free stencil and free worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

3. Layout and design

Partnering with quality service providers to offer design services.

4. Open source community

Student sponsorship shared PCB projects and so on.

5. 3D Printing & CNC

On-demand Production and Rapid Prototyping in as Fast as 1 Day Leading the Digital Manufacturing Revolution.

Step 1: Go to the PCBWay website and sign up/sign in. Into the PCB Prototype tab, enter the dimensions of your PCB, the number of layers, and the number of PCBs you require. After that proceed by clicking on the ‘Quote Now’ button.

Step 2: You will be redirected to a page where to set a few additional parameters like the board type, layers, material for PCB, thickness, and more, most of them are selected by default, if you are opting for any specific parameters, you can edit it in here.

Step 3: The final step is to upload the Gerber file and proceed with the payment. To make sure the process is smooth, PCBWAY verifies if your Gerber file is valid before proceeding with the payment. This way, you can be sure that your PCB is fabrication friendly.

Working Principle of Sound Sensor Based Thunder And Lightning Effect

This circuit is working like normal relay ON/OFF switching via sound sensor pulse signal. First, we need to adjust the sensitivity of the sound sensor through the pot. After setting the sound sensor, it acts like a switch used to activate the relay module.

The D0 pin of the sound sensor is connected to the D8 pin of the Arduino. Therefore D9 pin of the Arduino is used as the output of the circuit. It is also connected to any input pin (IN1) of the 5V relay module.

Here we define the initial output state to “LOW” when no sound is detected. When a small amount of sound will detect, the current will flow through the input pin of the relay module. In this situation, the circuit will go to the “HIGH” state. Note that this condition is working only when we connect the relay module to the output of the Arduino.

Otherwise, if we want to run a single LED or LED stripe, we need to change the code. In this situation, it should be set to “HIGH” while it is in an initial position. And when a sound will be detected, it will go to “LOW” condition.

Arduino Code

int soundSensor = 8;  //define sound sensor pin
int LED = 9;          //define relay input pin
void setup() 
{
  pinMode (soundSensor, INPUT); //define Sound Sensor as input
  pinMode (LED, OUTPUT);        //define LED Strip as output
}
void loop()
{
  int statusSensor = digitalRead (soundSensor);   //define variable of the sound sensor status
                                                  //and read value of the sensor's
  
  if (statusSensor == 1)        //When the Sensor detects a signal
  {
    digitalWrite(LED, LOW);
  }
  
  else                          //If no signal is detected
  {
    digitalWrite(LED, HIGH);
  }
  
} 

Video Output


Thunder And Lightning Effect Using DFplayer

Project

thunder and lightning effect using dfplayer

Circuit Diagram

Thunder and lightning effect using a dfplayer circuit

Components Required

  • Arduino Nano
  • DFplayer Mini Module
  • SD Card
  • 5V Relay Module
  • 1KΩ resistor (x2)

Circuit Design Using PCB Software

To make the circuit compact and give a professional look, I have designed the PCB after testing all the features of the thunder and lightning effect using a dfplayer on the breadboard. I will explain in detail how we can design and order PCB for our project.

Thunder and lightning effect using a dfplayer pcb

Gerber file for Thunder and lightning effect using a dfplayer.

Working Principle of DFPlayer Based Thunder And Lightning Effect

The working principle of DFPlayer based thunder and lightning effect is quite similar to the sound sensor circuit. But there is two extra advantage that is this can produce the lightning effect and thunder sound both.

The dfplayer collects data from the SD card and sends the output signal to the Arduino. TX, RX and BUSY pin of the dfplayer module then connect to pins D10, D11 and D12 of the Arduino as input.

Therefore a MOSFET is added to the circuit to amplify the signal from the Arduino. D9 pin of the Arduino then connects to the gate terminal of the IRFZ44N MOSFET as output. After amplifying the signal, it connects to the ground pin of the 5V relay module for activation. Another source terminal of the MOSFET will directly attach to the ground.

Now connect L DAC and R DAC are connected to a stereo amplifier for sound.

Thus this circuit first produces lightning and after a little delay, it produces sound also. It actually works as an original thunderstorm.

DFPlayer Arduino Library

To compile code to the Arduino we need a DFPlayer Mini Mp3 library file. You can just download this from the link.

Arduino Code

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
int ledPin = 9;    // Bulb Output
int rxPin = 10;    // DFplayer RX to Arduino pin 10
int txPin = 11;    // DFplayer TX toArduinopin 11
int busyPin = 12;  // DFplayer BUSY connected to pin 12
SoftwareSerial mySoftwareSerial(rxPin, txPin);
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(busyPin, INPUT);
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  Serial.println(F("Initializing DFPlayer..."));
  if (!myDFPlayer.begin(mySoftwareSerial)) 
  {  
   //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin. Check connection and SD card, or reset the Arduino."));
    while (true);
  }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.setTimeOut(500);                   // Set serial communictaion time out 500ms
  myDFPlayer.volume(30);                        // Set volume value (0~30).
  myDFPlayer.EQ(DFPLAYER_EQ_BASS);              // Set EQ to BASS (normal/pop/rock/jazz/classic/bass)
  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);  // Set device we use SD as default
  myDFPlayer.enableDAC();                       // Enable On-chip DAC
}
void loop()
{
  int flashCount = random (3, 15);        // Min. and max. number of flashes each loop
  int flashBrightnessMin =  10;           // LED flash min. brightness (0-255)
  int flashBrightnessMax =  255;          // LED flash max. brightness (0-255)
  int flashDurationMin = 1;               // Min. duration of each seperate flash
  int flashDurationMax = 50;              // Max. duration of each seperate flash
  int nextFlashDelayMin = 1;              // Min, delay between each flash and the next
  int nextFlashDelayMax = 150;            // Max, delay between each flash and the next
  int thunderDelay = random (500, 3000);  // Min. and max. delay between flashing and playing sound
  int thunderFile = random (1, 17);       // There are 17 soundfiles: 0001.mp3 ... 0017.mp3
  int loopDelay = random (5000, 30000);   // Min. and max. delay between each loop
  Serial.println();
  Serial.print(F("Flashing, count: "));
  Serial.println( flashCount );
  for (int flash = 0 ; flash <= flashCount; flash += 1) { // Flashing LED strip in a loop, random count
    analogWrite(ledPin, random (flashBrightnessMin, flashBrightnessMax)); // Turn LED strip on, random brightness
    delay(random(flashDurationMin, flashDurationMax)); // Keep it tured on, random duration
    analogWrite(ledPin, 0); // Turn the LED strip off
    delay(random(nextFlashDelayMin, nextFlashDelayMax)); // Random delay before next flash
  }
  Serial.print(F("Pausing before playing thunder sound, milliseconds: "));
  Serial.println(thunderDelay);
  delay(thunderDelay);
  Serial.print(F("Playing thunder sound, file number: "));
  Serial.println(thunderFile);
  myDFPlayer.playMp3Folder(thunderFile);
  delay(1000); // Give the DFPlayer some time
  while (digitalRead(busyPin) == LOW) { // Wait for the DFPlayer to finish playing the MP3 file
  }
  Serial.print(F("Pausing before next loop, milliseconds: "));
  Serial.println(loopDelay);
  delay(loopDelay);
}

Video Output

Leave a Comment