Sound Sensor with Arduino Tutorial – Music Reactive LEDs

A sound sensor is widely used in various applications, including voice activation, noise detection, and interactive lighting systems. It detects sound levels and provides an output signal that can be processed by a microcontroller. In this tutorial, we will explore how a sound sensor works and how to interface it with an Arduino to create a music-reactive LED system.

What is a Sound detection sensor?

Sound detection sensor module

A sound sensor detects variations in air pressure caused by sound waves and converts them into an electrical signal. It typically includes a microphone, an amplifier circuit, and an output stage that provides analog or digital signals representing the sound intensity.

Sound sensor pinout

Sound sensor module pinout

A typical sound sensor module consists of the following pins:

  • VCC – Power supply (3.3V to 5V)
  • GND – Ground
  • A0 – Analog output (provides variable voltage based on sound intensity)
  • D0 – Digital output (HIGH or LOW depending on a preset threshold)

Specifications

Below is a table with the specifications of a typical sound sensor:

ParameterSpecification
Operational Voltage Range3.3V – 5V
Operational Current4-5 mA
Voltage Gain26 dB (@6V, f=1kHz)
Microphone Sensitivity Range52 to 48 dB (1kHz)
Microphone Impedance2.2k Ohm
Microphone Frequency Range16 to 20 kHz
Signal-to-Noise Ratio54 dB

How does a sound sensor work?

Different parts of sound sensor module
Different parts of sound sensor module

The sound sensor consists of two main parts:

1. Microphone

The microphone detects sound waves and converts them into electrical signals. Most modules use an electret condenser microphone, which is sensitive to a wide range of frequencies.

2. Electronic Module

The electronic module processes the microphone signal and provides both analog and digital outputs. It includes:

  • LM393 Comparator – Converts the analog signal into a HIGH/LOW digital output based on a set threshold.
  • Potentiometer – Adjusts the sensitivity of the digital output (DO). Turning it clockwise increases sensitivity, while counterclockwise decreases it.
  • Power LED – Indicates that the module is powered.
  • Status LED – Lights up when the sound level exceeds the set threshold.

A sound sensor works by capturing sound waves through a microphone and converting them into electrical signals. When sound waves hit the microphone diaphragm, they create variations in air pressure.

These variations are translated into electrical signals, which are then amplified by an onboard amplifier circuit. The module processes these signals and provides both an analog output (A0) and a digital output (D0).

The analog output gives a continuous voltage representing sound intensity, while the digital output switches between HIGH and LOW based on a preset sensitivity threshold.

The Arduino reads these signals and can trigger actions like lighting up LEDs, activating alarms, or adjusting system responses based on the detected sound level.

Music-Reactive LEDs using a Sound sensor with Arduino

Now, let’s build a system where LEDs react to music or sound intensity in real time.

Components Required:

components required
  • Arduino UNO
  • Sound sensor module
  • LED x 3
  • 220 ohm resistor x 3
  • Jumper wires

Circuit Diagram

Sound sensor module with Arduino circuit diagram

Arduino Code for Music-Reactive LEDs:

const int soundSensor = 2;
const int redLed = 3;
const int greenLed = 5;
const int blueLed = 6;

void setup() {

  Serial.begin(9600);

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
}


void loop() {
  int soundValue = digitalRead(soundSensor);
  Serial.print("Sound Level:  ");
  Serial.println(soundValue);
  digitalWrite(redLed, soundValue);
  digitalWrite(greenLed, soundValue);
  digitalWrite(blueLed, soundValue);
  delay(10);
}

Code explanation

const int soundSensor = 2;
const int redLed = 3;
const int greenLed = 5;
const int blueLed = 6;
  • The sound sensor is connected to digital pin 2.
  • The RGB LED has its red, green, and blue components connected to pins 3, 5, and 6, respectively.
void setup() {
  Serial.begin(9600);
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
}
  • Serial.begin(9600); initializes serial communication at 9600 baud rate, allowing the microcontroller to send data to the Serial Monitor.
  • pinMode() sets the LED pins (red, green, blue) as OUTPUT since they control an LED.
void loop() {
  int soundValue = digitalRead(soundSensor);
  Serial.print("Sound Level:  ");
  Serial.println(soundValue);
  digitalWrite(redLed, soundValue);
  digitalWrite(greenLed, soundValue);
  digitalWrite(blueLed, soundValue);
  delay(10);
}
  • digitalRead(soundSensor); reads the digital value from the sound sensor (either 0 or 1).
  • Serial.print() and Serial.println() print the sound sensor’s value to the Serial Monitor.
  • digitalWrite() sets the LED states:
  • If soundValue == 1 (sound detected), all LEDs turn ON.
  • If soundValue == 0 (no sound detected), all LEDs turn OFF.
  • delay(10); adds a short delay of 10 milliseconds before the next reading.

How does the project work?

In this sound-reactive LED project, three LEDs—Red, Green, and Blue—are placed on a breadboard along with a sound sensor.

When a nearby speaker plays music, the sound sensor detects audio signals and converts them into electrical signals. These signals are processed by an Arduino, which analyzes the sound intensity and dynamically adjusts the brightness and color of the LEDs.

As the beats change, the LEDs respond in real time, creating a visually stunning sound-synchronized lighting effect. This project is perfect for DIY electronics enthusiasts, Arduino beginners, and those looking to create an interactive music visualization setup.

Conclusion

This music-reactive LED system is an exciting project that enhances visual effects in response to sound. By integrating a sound sensor with an Arduino, LEDs can react to music beats, claps, or any sound input, making it ideal for home decoration, parties, and interactive installations.

Photo of author

Vikas Gariyal

Electrical engineer by profession, I employ graphic design as a visual art to simplify and enhance electronic content for clarity and engagement, making complex ideas easily understandable. My work combines creativity and technology to create captivating and effective visual storytelling.

Leave a Comment