๐ถ OLED Audio Spectrum Analyzer
Visualize music as a real-time 7-band animated frequency spectrum on an OLED.
Overview
The MSGEQ7 is a dedicated audio equalizer IC that splits the audio spectrum into 7 bands (63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, 16kHz) and outputs each band's amplitude as an analog voltage. This project reads all 7 levels and renders an animated bar graph on a 128ร64 SSD1306 OLED.
What you'll learn: Audio signal path design, MSGEQ7 strobe/reset control, multiplexed analog reading, OLED graphics with the U8g2 library, and smooth peak-hold animations.
Estimated time: 2โ3 hours. Difficulty: โญโญโญ Intermediate.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Nano | 5V, ATmega328P | 1 | Compact for a final build |
| MSGEQ7 IC | PDIP-8 | 1 | 7-band spectrum analyzer chip |
| 0.96" I2C OLED | SSD1306 128x64 | 1 | Display output |
| Audio Jack 3.5mm | Stereo to mono mix | 1 | Input from phone/PC |
| 0.1ยตF & 33pF Caps | Ceramic | 2 each | MSGEQ7 filter network |
| 200kฮฉ Resistor | 1/4W | 1 | MSGEQ7 input bias |
Step-by-Step Tutorial
1
Build MSGEQ7 Filter Circuit
Connect Pin 1 (GND), Pin 2 (Vout โ A0), Pin 3 (GND), Pin 4 (Reset โ D5), Pin 5 (Strobe โ D4), Pin 6 (+5V), Pin 7 (Input via 0.1ยตF cap from audio). Add 33pF cap from Pin 8 to GND.
2
Wire the OLED
Connect OLED SDA โ A4, SCL โ A5, VCC โ 3.3V, GND โ GND on the Nano.
3
Install Libraries
Install
U8g2 by Oliver Kraus from Library Manager. It provides high-performance OLED graphics primitives.4
Read 7 Band Values
Toggle the Strobe pin LOW/HIGH 7 times. After each toggle, read A0 โ this gives the amplitude for each of the 7 frequency bands in sequence.
5
Render Animated Bars
Map each band value (0โ1023) to a bar height (0โ64 pixels). Draw filled rectangles for bars and track a falling peak dot per band for a professional VU meter look.
Audio signals from headphone jacks are very weak (millivolts). Add a non-inverting op-amp gain stage (e.g., TL072 with 10x gain) before the MSGEQ7 input for much stronger, cleaner bar graphs.
Code / Configuration
oled_spectrum.ino
INO
// OLED Audio Spectrum Analyzer - Volt X
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
const int strobePin = 4;
const int resetPin = 5;
const int audioPin = A0;
int spectrum[7];
int peaks[7];
int peakHold[7];
const char* freqLabels[] = {"63", "160", "400", "1k", "2.5k", "6.25k", "16k"};
void readMSGEQ7() {
digitalWrite(resetPin, HIGH); delayMicroseconds(5);
digitalWrite(resetPin, LOW);
for (int i = 0; i < 7; i++) {
digitalWrite(strobePin, LOW); delayMicroseconds(36);
spectrum[i] = analogRead(audioPin);
digitalWrite(strobePin, HIGH); delayMicroseconds(1);
}
}Reviews & Ratings
โ0 reviews
Sign in to leave a review
Loading reviews...