Skip to content

DanhLent/STM32-Neopixel-Audio

Repository files navigation

STM32 WS2812B Music Visualizer & Light Show

License: MIT

Introduction

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.


Table of Contents


Demo

https://www.youtube.com/watch?v=HTsP6H0X7IE


Key Features

  • 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.

Hardware & Software Requirements

Hardware

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

Software


Pinout Configuration

Screenshot 2025-07-20 130626

Peripheral Configuration

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. image

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.

image image

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.

image image

Installation

Click to view installation guide
  1. Clone the repository to your local machine:
    git clone https://github.com/DanhLent/STM32-Neopixel-Audio.git
  2. Open the project in STM32CubeIDE, connect the hardware according to the pinout diagram, then build and flash to the board.

Credits

Releases

No releases published

Packages

No packages published

Languages