Skip to the content.

Audio Visualizer

My project, the Audio Visualizer, was an interesting project that had challenges. I had to switch displays because of power issues, but in the end, I have no regrets. The project has a display which shows the audio visualizer bars on the screen, in live reaction to music or sound. It’s really satisfying to see the visuals respond instantly to changes in the audio, bringing the sound to life in a new way.

Engineer School Area of Interest Grade
Harini P West High School Software Engineering Incoming Freshman

Headstone Image

Final Milestone


Since milestone 2, I’ve worked around my error succesfully. The screen is now fully reacting to all sound smoothly. Instead of drawing rectangles for each bar, which was slow, I instead drew 2 verticle lines for them. The bars were being drawn faster, but they still weren’t going away. To solve that issue, I drew two black lines over the bars to seemingly erase them before the new ones came in, fixing the error completely. My biggest challenge at BSE was probably this error. Before solving it, I was thinking about just switching back to the LED Matrix. Thankfully, I pushed on, leading me into one of my triumphs: fixing the error! My other triumph was being able to code for the TFT LCD display without even having it on hand! Luckily for me, I didn’t need to do much debugging, only fixing the frozen screen! Over my time at BSE, I learned many new things about audio. I’ve learned about the Fast Fourier Transform (FFT), which is a method that breaks down sound into smaller pieces and analyzes their frequencies. I also learned more about frequencies annd a little about PWM (Pulse Width Modulation) which is a technique that controls the amount of power delivered to a device by varying the duration of pulses in a signal. After BSE, I hope to be able to continue exploring about audio in general, as it interests me a lot.

Second Milestone


Since my second milestone, I’ve figured out my modification. My modicfication is that the bars will be relfected over a line in the center of the display, and the louder portions will be red and the quieter parts will be blue. A challenge that I faced while working toward my modification, was that I was orginally planning to use a rainbow LED display. After some extra research, we figured out that the display was unable to be supported by my Arduino due to power issues. So, we had to find an entirely new way to display the Audio visualizer. So, we decided to use a TFT LCD display. It’s liek a mini phone screen, which made it easier. I also had to code for a part I didn’t have on hand, which was challenging at first, but ended up working out as I did not need to debug anything! A challenge I am facing right now, though, is that the rate at which the frames of the bars are changing is too slow. It often gets stuck at one place. So, before my final milestone, my goal is to fix the frames so they move somewhat smoothly.

First Milestone


My project is a DIY audio visualizer using an Arduino Nano, a 32×8 MAX7219 LED matrix, and a microphone module. The goal is to capture live audio, analyze it using the Fast Fourier Transform (FFT), and display the sound frequencies as moving bars on the LED matrix. The Arduino reads analog sound data from a microphone connected to pin A0 and uses the arduinoFFT library to convert that sound into its frequency components. These frequency values are then mapped to visual bar heights, which are displayed in real-time on the LED matrix using the MD_MAX72XX library. One of the challenges I faced was fine-tuning sensitivity for my environment. Thankfull, I found the optimal sensitivity (4.9). The other challenge that I am facing is that there seem to be 2 filled bars at the left hand side of my matrix. They are due to other noises that my mic is picking up. I would like to resolve this issue moving forward. I also plan to explore more visual effects and possibly expand to a color LED matrix for a cooler look.

Schematics

Headstone Image

Code

#include <arduinoFFT.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>

#define TFT_CS     10
#define TFT_RST    8
#define TFT_DC     9

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
arduinoFFT FFT = arduinoFFT();

double vReal[64];
double vImag[64];
float sensitivity = 2;

void setup() {
  tft.initR(INITR_BLACKTAB);
  tft.setRotation(3);
  tft.fillScreen(ST77XX_BLACK);
}

void loop() {
  for (int i = 0; i < 64; i++) {
    vReal[i] = analogRead(A0) / sensitivity;
    vImag[i] = 0;
  }

  FFT.Windowing(vReal, 64, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
  FFT.Compute(vReal, vImag, 64, FFT_FORWARD);
  FFT.ComplexToMagnitude(vReal, vImag, 64);

  for (int i = 0; i < 32; i++) {
    vReal[i] = constrain(vReal[i], 0, 80);
    int h = map(vReal[i], 0, 64, 0, 64);
    int limit = 32;
    int quietHeight = min(h, limit);
    int loudHeight = max(h - limit, 0);
    int x = i * 5;

    // Only draw 2 lines (centered in each 5px-wide bar)
    int barX = x + 1;

    // === TOP ===
    // Clear (black) from top to just above the active line
    tft.drawFastVLine(barX, 0, 64 - h, ST77XX_BLACK);

    // Draw quiet + loud lines
    tft.drawFastVLine(barX, 64 - quietHeight, quietHeight, ST77XX_RED);
    tft.drawFastVLine(barX, 64 - h, loudHeight, ST77XX_BLUE);

    // === BOTTOM ===
    // Clear (black) from bottom up to below the active line
    tft.drawFastVLine(barX, 64 + h, 128 - (64 + h), ST77XX_BLACK);

    // Draw mirrored quiet + loud lines
    tft.drawFastVLine(barX, 64, quietHeight, ST77XX_RED);
    tft.drawFastVLine(barX, 64 + quietHeight, loudHeight, ST77XX_BLUE);

    tft.drawFastVLine(1,0,128 , ST77XX_BLACK);
    tft.drawFastVLine(6,0,128 , ST77XX_BLACK);
  }

  delay(5);
}

Bill of Materials

Part Note Price Link
Bewinner 1.8inch LCD Display Module, TFT Screen Module Displaying the bars $8.99 Link
ELEGOO UNO R3 Project Most Complete Starter Kit Used the arduino, wires, breadboard $59.99 Link