Thunder And Lightning Effect System: Today we are going to build a cool project that is the thunder and lightning effect using Arduino. Lightning is the most spectacular part of a thunderstorm. In fact, it is how thunderstorms got their 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, a sound sensor and dfplayer. This project is useful for photography and videography studio to make an artificial lighting effects 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 the 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 sending signals to Arduino. The Arduino then produces an output signal and glows 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
Circuit Diagram
Components Required
- Arduino Nano
- Sound Sensor Module
- 5V Relay Module
- AC Bulb
- 9V Battery
Features of PCBWay
1. PCB prototyping and manufacturing
They produce FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at a very reasonable price.
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 the 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.
Working Principle of Sound Sensor Based Thunder And Lightning Effect
This circuit is working like a 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 the “LOW” condition.
Arduino Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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); } } |
Thunder And Lightning Effect Using DFplayer
Project
Circuit Diagram
Components Required
- Arduino Nano
- DFplayer Mini Module
- SD Card
- 5V Relay Module
- 1KΩ resistor (x2)
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 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 pins 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. The 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #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); } |