Back to All Blog Posts
Tutorial •EltroNerd Engineering

ESP32 Music Visualizer with LED

ESP32 Music Visualizer with LEDs is a perfect mix of IoT, embedded systems, and signal processing.

šŸŽµ ESP32 Music Visualizer with LEDs


šŸ“Œ 1. Introduction

A music visualizer converts audio signals into dynamic visual effects.
In this project, an ESP32 reads sound from a microphone module, processes the signal, and drives addressable LEDs (WS2812B/Neopixel or RGB strips) to create colorful visual patterns that react to music beats.


šŸŽÆ 2. Objectives

  • To design a low-cost audio visualizer using ESP32.
  • To capture real-time sound input via a microphone/ADC.
  • To display LED patterns based on sound intensity and frequency.
  • To understand the application of FFT (Fast Fourier Transform) in audio processing.

āš™ļø 3. Hardware Requirements

  • ESP32 Development Board
  • Microphone Module (MAX9814 / MAX4466 / INMP441 I²S Mic)
  • WS2812B Addressable LED Strip (Neopixel)
  • 5V Power Supply (depending on LED strip length)
  • Jumper wires, breadboard

šŸ”Œ 4. Circuit Connections

ESP32 → Microphone (I²S INMP441 example)

  • INMP441 SCK → GPIO14
  • INMP441 WS → GPIO15
  • INMP441 SD → GPIO32
  • VCC → 3.3V
  • GND → GND

ESP32 → WS2812B LED Strip

  • Data Pin → GPIO5
  • VCC → 5V
  • GND → GND

šŸ“œ 5. Arduino Code (Basic Music Visualizer)

c
#include <FastLED.h>

#define LED_PIN     5
#define NUM_LEDS    60
#define BRIGHTNESS  180
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB

CRGB leds[NUM_LEDS];

// Microphone pin (Analog)
#define MIC_PIN 34  

void setup() {
  Serial.begin(115200);
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);
}

void loop() {
  int micValue = analogRead(MIC_PIN); // Read sound level
  int level = map(micValue, 0, 4095, 0, NUM_LEDS); // Scale to LED count

  // Light up LEDs based on sound intensity
  for (int i = 0; i < NUM_LEDS; i++) {
    if (i < level) {
      leds[i] = CHSV(map(i, 0, NUM_LEDS, 0, 255), 255, 255);
    } else {
      leds[i] = CRGB::Black;
    }
  }
  FastLED.show();
  delay(10);
}

šŸ”Ž Working Principle

The ESP32 music visualizer works as follows:

  1. Audio Signal Capture

    • A microphone module (MAX9814 / INMP441 / MAX4466) detects sound vibrations from music or voice.
    • The analog or I²S digital signal is fed into the ESP32.
  2. Signal Processing

    • The ESP32 reads the sound level using its ADC (analog-to-digital converter).
    • The amplitude (loudness) of the signal is calculated in real time.
    • (Optional: FFT can be applied to split the signal into bass, mid, and treble frequency bands).
  3. LED Mapping

    • The processed sound values are mapped to brightness, color, and number of LEDs.
    • Louder music lights up more LEDs, while softer sounds light fewer.
    • Colors shift dynamically (e.g., rainbow effects using HSV mode) to make the visualization attractive.
  4. Real-Time Visualization

    • The LED strip updates continuously, creating a visual effect that reacts instantly to music beats and rhythm.

šŸ Conclusion

The ESP32 Music Visualizer with LEDs demonstrates how sound signals can be transformed into real-time visual effects.
By combining an ESP32 microcontroller, a microphone module, and addressable LEDs, the system successfully converts music loudness and rhythm into dynamic light patterns.

Key outcomes:

  • Provides an interactive and entertaining way to visualize sound.
  • Teaches students the fundamentals of signal processing, ADC sampling, and LED control.
  • Serves as a foundation for advanced visualizers using FFT frequency analysis for richer effects.

This project is not only a fun DIY application but also a practical embedded systems experiment that blends electronics, programming, and creativity.

Try this project in your browser

Compile code and simulate hardware output with EltroNerd Cloud IDE.

Launch Cloud IDE