The visualizer
Every lesson opens on the same wiring:
- The line in: two signal generators, a bass note at 125 Hz and a treble note at 1250 Hz, both riding on 2.5 V and mixed through two 10k resistors into A0.
- The microphone: a KY-038 sound module on A1, for claps and beats.
- The lights: a 16 x 8 WS2812 panel on pin 6.
- THEME: a pushbutton on pin 2.
The catalog lists an ESP32 with an INMP441 I2S microphone. The Uno has no I2S, and the simulated INMP441 gives a level rather than a waveform to transform, so this build samples an analog line in on the Uno's own ADC.
How it works
Levels. 64 samples, 250 microseconds apart: 4000 a second. RMS says how loud a passage is, the peak catches claps and drums. The KY-038 has no amplifier, so ordinary sound moves the ADC by a count or two: it is a clap detector, and the music comes in on the line in.
The FFT. A 64 point radix 2 FFT in 16 bit whole numbers, each stage halving its results so nothing overflows. Each bin is 62.5 Hz up to the 2000 Hz Nyquist limit; a 3000 Hz tone aliases to 1000 Hz. The 32 bins become 8 bands that double in width, an octave each, at 4 dB a LED.
Beats. A block of microphone sound more than three times the running average is a beat, with a 250 ms lockout. The gaps between beats give the tempo.
Bars and themes. Eight bands two columns wide, with peak dots that fall a LED every 150 ms. Themes color each LED by its height (fire, ocean) or its column (rainbow), at low brightness: a full white panel would draw over 7 A.
The party wall. Everything at once, plus an auto gain that scales the loudest band to fill the panel but never boosts more than 8 times.
The course
Build a music visualizer gets there in six lessons, each a sketch on the same wiring:
- Microphone levels: RMS, peaks, and a microphone with no amplifier.
- Bands with FFT: bins, octave bands and aliasing.
- Beat flash: beats and tempo.
- Matrix bars: a spectrum analyzer on the panel.
- Color themes: fire, ocean and rainbow.
- Project: a party wall: all of it, with auto gain.
Every step but the last is checked against the running circuit.