This repository contains the source code for an academic project demonstrating a real-time, audio-reactive light show. The system utilizes an STM32F407VET6 microcontroller to drive a WS2812B (Neopixel) addressable LED strip, creating visual effects including a vibrant rainbow wave and a dynamic music visualizer. A user-friendly interface is implemented with an LCD and a rotary encoder for seamless effect selection.
- Demo
- Key Features
- Hardware & Software Requirements
- Pinout Configuration
- Peripheral Configuration
- Installation
- Credits
https://www.youtube.com/watch?v=HTsP6H0X7IE
- Real-time Music Visualization: Analyzes audio intensity from a microphone to generate synchronized lighting effects.
- Dynamic Lighting Effects: Includes a smooth, pre-programmed "Rainbow Wave" effect.
- Interactive UI: A simple interface with an ILI9341 LCD and a Rotary Encoder allows for easy navigation and mode switching.
Component | Model | Role |
---|---|---|
Microcontroller | STM32F407VET6 | Central processing, controls all peripherals |
LED Strip | WS2812B (Neopixel) | Displays visual effects |
Audio Module | MAX9814 Microphone | Captures ambient sound |
Display | ILI9341 TFT LCD | Displays the user interface |
Input | Rotary Encoder | User input for menu navigation |
Power Supply | 5V, 3A | Powers the MCU and LED strip |
- STM32CubeIDE
- An ST-Link programmer/debugger

Key peripherals were configured for optimal performance. Below are screenshots of the main settings in STM32CubeIDE.
System Clock Configuration
The system is configured to run at a maximum frequency of 72MHz, derived from an 8MHz external crystal oscillator (HSE). This ensures the highest processing performance for effect algorithms and audio analysis.
TIM1 for WS2812B (PWM & DMA)
Timer 1 is configured to generate an 800kHz PWM signal, precisely matching the WS2812B protocol's requirements. Calculation: 72,000,000 Hz / (Period + 1) = 800,000 Hz. DMA is set to Memory-to-Peripheral mode to automatically transfer data, completely offloading the CPU.


TIM2 & ADC1 for Audio Sampling
Timer 2 acts as a trigger for ADC1 to ensure a consistent audio sampling rate. ADC1 and DMA are configured in Circular Mode to continuously sample audio data into a buffer without CPU intervention.


Click to view installation guide
- Clone the repository to your local machine:
git clone https://github.com/DanhLent/STM32-Neopixel-Audio.git
- Open the project in STM32CubeIDE, connect the hardware according to the pinout diagram, then build and flash to the board.
- The ILI9341 LCD driver is based on the STM32-ILI9341-FSMC-Library.
- The rainbow effect algorithm is inspired by the work of Adriano Tiger's Neopixel Effect Generator.