Skip to content

support@quartzcomponents.com

Free Shipping Over INR 500

Electronics Projects

Sound Level Detector using Arduino Nano and Analog Sound Sensor Module

by RISHABH JANGID 27 Apr 2026 0 Comments

This project is a real-time sound level visualization system that converts ambient noise into a clear visual output. A Analog Sound Sensor captures surrounding sound, the Arduino Nano processes the signal, and LED strip represents the intensity as a growing or shrinking light bar.
In practical scenarios, this type of system acts as a noise indicator. In classrooms, it can signal when students become too loud. In offices or libraries, it helps maintain a controlled environment without constant monitoring. In events or music setups, it works as a basic audio visualizer, reacting instantly to beats and volume changes.


The system is built on three functional layers:

Microphone sensor → captures analog sound signals from the environment
Arduino Nano → analyzes signal amplitude and converts it into usable data
LED strip → provides immediate visual feedback based on sound intensity


Components Required

About Components

Arduino Nano

The Arduino Nano is a compact, breadboard-friendly microcontroller based on the ATmega328P, now upgraded with a modern Type-C interface.

  • Operating Voltage: 5V
  • Input Voltage (VIN): 7V to 12V
  • Microcontroller: ATmega328P (8-bit AVR)
  • Clock Speed: 16 MHz
  • Flash Memory: 32 KB (2 KB used by bootloader)
  • SRAM / EEPROM: 2 KB / 1 KB
  • Digital I/O Pins: 14 (out of which 6 provide PWM output)
  • Analog Input Pins: 8 (10-bit resolution)

Sound Sensor Module

This module uses a high-sensitivity capacitive electret microfphone and an LM393 comparator for real-time sound detection.

  • Operating Voltage: 3.3V to 5V
  • Output Type: Dual Output (Analog & Digital)
  • AO (Analog Output): Real-time voltage signal from the microphone.
  • DO (Digital Output): High/Low signal based on the sound threshold.
  • On-board Features: Integrated potentiometer (sensitivity adjustment knob) to set the sound threshold.
  • Comparator: LM393 low-power voltage comparator.

WS2812 8 Bit RGB LED Strip

The WS2812 is an intelligent, individually addressable LED light source that integrates the control circuit and RGB chip in one package.

  • Operating Voltage: 5V DC
  • LED Type: 5050 RGB LEDs with built-in WS2811 driver IC.
  • Interface: Single-wire communication (One data pin controls all 8 LEDs).
  • Data Transfer Speed: 800 Kbps
  • Color Depth: 24-bit (8-bit per channel, providing 16.7 million color combinations).
  • Brightness: Each color has 256 levels of brightness adjustment.

Working

  1. Microphone picks up sound
  2. Arduino reads the sound signal
  3. It checks how strong the sound is
  4. According to sound level, LEDs turn on
  5. Color changes from:
    • Green → low sound
    • Yellow → medium
    • Red → high sound

Analog Signal

Sound sensor gives an analog signal, which means the voltage keeps changing continuously based on sound.
Arduino reads this using analogRead(), which converts the voltage (0–5V) into a value from 0 to 1023.
Since sound keeps changing, the code takes the difference between highest and lowest values (peak-to-peak) to find how strong the sound is.
More value = louder sound → more LEDs turn on.

Circuit Connections

Fig. Circuit Diagram

Fig. Schemetic Diagram

Sound Sensor

  • VCC → 5V
  • GND → GND
  • OUT → A0

LED Strip

  • VCC → 5V
  • GND → GND
  • DIN → D8

Code Explanation

Libraries Used

Libraries
 #include <Adafruit_NeoPixel.h> 

Purpose of Library

  • Adafruit_NeoPixel → Controls WS2812/NeoPixel LED strip and manages color + brightness

Pin Definitions

Pin Definitions
#define MIC_PIN A0 // microphone input
#define LED_PIN 8 // LED data pin
#define NUM_LEDS 8 // total LEDs
  • Microphone connected to analog pin A0
  • LED strip data connected to digital pin 8
  • Total LEDs defined for scaling output

Sensitivity Configuration

Threshold Settings
const int sampleWindow = 40; // ms sampling time
int inputFloor = 40; // minimum noise level
int inputCeil = 180; // maximum expected level
  • Defines how long sound is sampled
  • Filters background noise
  • Controls sensitivity range

Smoothing Variables

Smoothing
float currentLevel = 0;
float falloffRate = 0.5;
  • Prevents flickering
  • Creates smooth LED transitions

Setup Function

setup()
void setup() { 
Serial.begin(115200);
strip.begin();
strip.setBrightness(50);
strip.show();
}
  • Initializes serial communication
  • Starts LED strip
  • Sets brightness level
  • Turns off LEDs initially

Reading Sound Signal

Sampling
unsigned long startMillis = millis();
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
  • Captures time window
  • Tracks max and min signal

Collecting Data

Signal Capture
while (millis() - startMillis < sampleWindow) {
int sample = analogRead(MIC_PIN);
if (sample < 1024) {
    if (sample > signalMax) signalMax = sample;
    else if (sample < signalMin) signalMin = sample;
}
}
  • Reads multiple samples
  • Finds peak and lowest values
  • Represents sound amplitude

Sound Level Calculation

Peak-to-Peak
int peakToPeak = signalMax - signalMin; 
  • Calculates signal strength
  • Higher value → louder sound

Mapping to LEDs

Mapping
float targetLevel = map(peakToPeak, inputFloor, inputCeil, 0, NUM_LEDS);
targetLevel = constrain(targetLevel, 0, NUM_LEDS);
  • Converts sound into LED count
  • Ensures value stays within limits

Smoothing Output

Smoothing Logic
if (targetLevel > currentLevel) {
currentLevel = targetLevel;
}
else {
currentLevel -= falloffRate;
} if (currentLevel < 0) currentLevel = 0;
  • Fast rise, slow fall behavior
  • Eliminates jitter

Result

System converts real-time sound input into a dynamic LED bar. Louder sound increases LED count, while silence gradually reduces it. Output remains stable due to smoothing and threshold filtering.

Real-Life Applications

  • Audio Visualizer — Real-time music visualization
  • Noise Monitoring — Detect loud environments
  • Interactive Installations — Sound-reactive lighting systems
  • Signal Strength Indicator — Analog signal visualization concept
  • Educational Demonstration — Analog signal processing and mapping

Checkout the full video tutorial:

 

Code

Complete Sketch
#include <Adafruit_NeoPixel.h>

#define MIC_PIN A0
#define LED_PIN 8
#define NUM_LEDS 8

Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

// -------- Sensitivity --------
const int sampleWindow = 40;
int inputFloor = 40;
int inputCeil = 180;

// -------- Smoothing --------
float currentLevel = 0;
float falloffRate = 0.5;

void setup() {
Serial.begin(115200);

strip.begin();
strip.setBrightness(50);
strip.show();

}

void loop() {

// -------- Sampling --------
unsigned long startMillis = millis();

unsigned int signalMax = 0;
unsigned int signalMin = 1024;

while (millis() - startMillis < sampleWindow) {

    int sample = analogRead(MIC_PIN);

    if (sample < 1024) {

        if (sample > signalMax) {
            signalMax = sample;
        }
        else if (sample < signalMin) {
            signalMin = sample;
        }
    }
}

// -------- Calculate Level --------
int peakToPeak = signalMax - signalMin;

Serial.print("Volume: ");
Serial.println(peakToPeak);

// -------- Map to LEDs --------
float targetLevel = map(
    peakToPeak,
    inputFloor,
    inputCeil,
    0,
    NUM_LEDS
);

targetLevel = constrain(targetLevel, 0, NUM_LEDS);

// -------- Smooth Output --------
if (targetLevel > currentLevel) {
    currentLevel = targetLevel;
} else {
    currentLevel -= falloffRate;
}

if (currentLevel < 0) {
    currentLevel = 0;
}

// -------- Update LEDs --------
strip.clear();

for (int i = 0; i < NUM_LEDS; i++) {

    if (i < currentLevel) {

        // simple green bar
        strip.setPixelColor(i, strip.Color(0, 150, 0));

    } else {

        strip.setPixelColor(i, strip.Color(0, 0, 0));
    }
}

strip.show();

}
Prev Post
Next Post

Leave a comment

Please note, comments need to be approved before they are published.

Thanks for subscribing!

This email has been registered!

Shop the look

Choose Options

Edit Option
Back In Stock Notification
is added to your shopping cart.
this is just a warning
Login