This project is about monitoring the sound level data that is being released, produced or outputted(?) by the speakers.
Aaah... this is a product of curiosity and boredom.
I used a [KY-038] microphone sound sensor module to pickup the values that I then gathered from the Serial Monitor, transferred to a spreadsheet, arranged to ascending order then chose the values that occurs more repetitively than others or just the ones that I like.
I picked a number of variables from the lowest range to the mid and high range.
The variables from the lowest range of values will activate the Yellow LEDs, the mid range ones will activate the Green LEDs and the high range ones will activate the Red ones.
The LEDs will be activated or turned on when the certain sensorValue is reached or detected by the sound sensor.
I also included an optional LCD to view the values in real time just for fun.
I basically just upgraded this code
The LCD Codes are from my previous project
And Username MAS3's Comment here
I encountered a problem where the data that is appearing on the LCD have some leftover digits from the past sensorValue. Like, when the current value is supposed to be 619 which is what is on the Serial Monitor, but it becomes 6194, because the past value was 1234.
Download the .cpp and .h files here.
******************************************************************************
Social Media Links To Follow (I mean, if you want to):
Facebook - https://fb.me/HeathenHacks
Twitter - https://twitter.com/HeathenHacks
Instagram - https://instagr.am/HeathenHacks
******************************************************************************

https://drive.google.com/file/d/15NRocdFjr-DG7Hu2zyyvSvRz7bcncvU7/

🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
Detecting sound isn't just listening for a "beep"—it’s mathematical voltage geometry. The Sound Sensor Activated LEDs with LCD utilizes an Analog Condenser Microphone breakout board. It forces the physical Arduino analog pins (A0) to furiously calculate the exact Peak-to-Peak voltage amplitude of physical sound-waves in the air, converting raw noise mathematics into a dazzling graphical LED bar graph and real-time LCD numerical output!
The Peak-To-Peak ADC Window Array
If you simply use analogRead(A0), the numbers are utterly meaningless. An audio wave technically oscillates wildly Up to 5V and Down to 0V a thousand times a second!
- If you read the pin at the exact millisecond the wave is crossing the middle, it outputs
0even if someone is screaming! - The Execution Trap: You must use a literal, high-speed Sampling Window Loop!
unsigned long startMillis = millis();
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
// Literally lock the CPU for 50 milliseconds directly listening to the screaming audio wave!
while(millis() - startMillis < 50) {
int sample = analogRead(A0);
if (sample > signalMax) { signalMax = sample; } // Capture the highest physical peak!
if (sample < signalMin) { signalMin = sample; } // Capture the lowest physical trough!
}
int peakToPeak = signalMax - signalMin; // The absolute volume magnitude integer!
Map() Rendering the LED Subnet
The final peakToPeak integer output provides the pure volume levels!
Quiet Room = 10.Clapping = 500.Screaming locally = 900.- The code uses
<map()>to convert(0, 1023)into a scalable chunk of Outputs:(0, 5). - If the number resolves to
3, the Arduino violently commands:digitalWrite(LED_GREEN1, HIGH); digitalWrite(LED_GREEN2, HIGH); digitalWrite(LED_YELLOW, HIGH); - ...While blasting exactly
"Decibel Peak: 400"dynamically written onto the I2C 16x2 LCD Character Matrix simultaneously!
Condenser Amplifier Needs
- Arduino Uno/Nano (Standard execution speeds are perfectly sufficient).
- Analog Sound Sensor Module (e.g., MAX4466 or KY-037) (Must utilize an amplifier chip natively. DO NOT use the digital output pin
D0! The digital pin only outputs an identical 1/0 binary ON/OFF signal; you absolutely demand the raw audio voltage sine-wave provided strictly on theA0analog pin!). - Array of 5mm LEDs (Green, Yellow, Red).
- 16x2 I2C Display Module (To visually plot the raw integer Peak-to-Peak thresholds).