กลับไปหน้ารวมไฟล์
sound-sensor-activated-leds-with-lcd-for-sound-level-data-283bad.md

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

Added some codes from here

And here

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/

You can also check the video.

https://youtube.com/@HeathenHacks


🛠️ เจาะลึกเบื้องหลังการทำงาน (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!

  1. If you read the pin at the exact millisecond the wave is crossing the middle, it outputs 0 even if someone is screaming!
  2. 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 the A0 analog pin!).
  • Array of 5mm LEDs (Green, Yellow, Red).
  • 16x2 I2C Display Module (To visually plot the raw integer Peak-to-Peak thresholds).

ข้อมูล Frontmatter ดั้งเดิม

title: "Sound Sensor Activated LEDs with LCD for Sound Level Data!"
description: "Just a basic sound sensor activated LEDs with an optional LCD for sound level data. ***STROBE LIGHT EFFECT AT AROUND 8:45 MINUTE MARK!***"
author: "Heathen_Hacks-v2"
category: "Lights & LEDs"
tags:
  - "audio"
  - "lights"
  - "entertainment system"
  - "monitoring"
views: 36128
likes: 18
price: 699
difficulty: "Easy"
components:
  - "1x 9V to Barrel Jack Connector"
  - "4x 5 mm LED: Green"
  - "1x Standard LCD - 16x2 White on Blue"
  - "1x Arduino UNO"
  - "8x Resistor 100 ohm"
  - "2x 5 mm LED: Red"
  - "4x Resistor 220 ohm"
  - "4x 5 mm LED: Blue"
  - "1x Sound Sensor Module KY-038"
  - "1x Male/Male Jumper Wires"
  - "1x Solderless Breadboard Full Size"
  - "1x Male/Female Jumper Wires"
  - "2x 5 mm LED: Yellow"
  - "4x Resistor 330 ohm"
  - "4x 5 mm LED: White"
  - "1x 9V battery (generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "88c9cbf18a2745bdaec0a98fece8529466a4fbcb54f61f5f63c9020f307d91b8"
encryptedPayload: "U2FsdGVkX18gfR1fQ86H+Mn0jH1AoUWxg/ggJCNhLO84VzFh+iHoIiTOH0l7a20jwTlXv7XHHw24flBqqwdH7+FwY48jqmMQYk6LAFLbL9M="
seoDescription: "Basic project using a Sound Sensor to control LEDs with an optional LCD for sound level data monitoring."
videoLinks:
  - "https://www.youtube.com/embed/QwDQgP_fGNo"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/sound-sensor-activated-leds-with-lcd-for-sound-level-data-283bad_cover.jpg"
lang: "en"