0

Led matrix audio visualizer using ESP32

sorry we are not native speakers, so the content may not be clear. We just want to share with you!
5 sao

sorry we are not native speakers, so the content may not be clear. We just want to share with you!

For entertainment when working or studying, we often listen to music, right? So, with a little LED MATRIX along with the music, it will help the song and the melody more lively, right!

Led matrix hub75

Prepare to DIY led matrix audio visualizer

  • ESP32
  • Max9814 (Microphone Amplifier with AGC)
  • Led matrix (HUB75 – 32×16 – P5)
  • 12V ADC (adapter)

About ESP32:

  • ESP32 WiFi, Bluetooth LE SoC – 240Mhz – Module ESP-WROOM-32
  • Automatic select 3 power sources (DC6-28V, USB and Battery)
  • Auto download Flash mode
  • Integrated SDCARD slot (support 1-bit mode)
  • Open hardware design with KiCad, CC-BY-SA license.
  • I2C OLED display header
  • Lithium-Ion Battery Charger
  • 1 Reset button, 1 programable button
  • 1 Power LED, 1 programable LED, 1 Charger LED
  • Compatible with Shields for ESP32 in the future (Gateway – GSM/GPRS/GPS and Lora Shield, Connectivity – CAN, RS485, RS232 Shield, Audio Shield, …

About MAX9814:

  • Supply Voltage: 2.7v-5.5v @ 3mA current
  • Output: 2Vpp on 1.25V bias
  • Frequency Response: 20Hz – 20 KHz
  • Programmable Attack and Release Ratio
  • Automatic gain, selectable max from 40dB, 50dB or 60dB
  • Low Input-Referred Noise Density of 30nV/ Square Hz
  • Low THD: 0.04% (typ).

About Led matrix HUB75:

Pixelpitch4mm4mm
Modulesize256mm * 128mm256mm * 128mm
Resolutionofmodule64*32Dots64*32Dots
Densityofpixel62,500dots/m262,500dots/m2
LEDSizeSMD2121SMD2121
Pixelconfiguration1R1G1B1R1G1B
Bestviewingdistance≥ 4M≥ 4M
Horizontalviewingangle140 °140 °
Viewingangle140 °140 °
Drivingmethod1/16scan1/32scan
Brightness1000 ~ 1200cd/m2≥800cd/m2
Refreshrate≥ 1920Hz≥ 1920Hz
IPgradeIP20IP20
Maxpowerconsumption20 Wat/pcs15 Wat/pcs
Avgpowerconsumption6.7 wst/pcs5 Wst/pcs
InputvoltageDC5VDC5V
Storagetemperature-40 °C ~ 65 °C-40 °C ~ 65 °C
Workingtemperature-20 °C ~ 55 °C-20 °C ~ 55 °C
MTBF≥ 10,000 h≥ 10,000 h
Longevity≥ 100,000 h≥ 100,000 h
Led matrix hub75 Specifications

Reference: https://www.tindie.com/products/rorosaurus/esp32-hub75-led-matrix-driver-kit/

Hardware connection

  • Connect OUT PIN (MAX9814) to PIN 34 (ESP32)
  • Using the ESP32’s GPIO pins and through two 74HC translation ICs to push data from the ESP to the Hub75.
ESP32 schematic connect to HUB75

Programming ESP32 read Max9814 to control led matrix HUB75

Include Megunolink and Filter library

=> Helps to read the parameters from the Max9814 sound sensor better.

Include library

Include led matrix library

=> Help ESP32 scan led better, use DMA to scan higher speed

Use the input sound intensity signal from the Max981 sensor as an output for the LED display to flash along with beautiful music. Depending on your preferences and purposes, adjust the code to be more suitable and beautiful!

#include<MegunoLink.h>
#include<Filter.h>

#include <ESP32-RGB64x32MatrixPanel-I2S-DMA.h>
RGB64x32MatrixPanel_I2S_DMA matrix(32, 16);

#define NOISE 550 // 550
#define MIC_PIN 34
#define led 22

int lvl = 0; // tweak the min and max as needed
ExponentialFilter<long> ADCFilter(5,0);

void setup() {
  // put your setup code here, to run once:
  //
  Serial.begin(115200);
  //pinMode(Red, OUTPUT);
  
  matrix.begin();
  matrix.fillScreen(0);
  matrix.setPanelBrightness(20);
    

  for(int k =31; k>= 0 ;k--) {
      for(int h = 15; h >= 0 ;h--) {
        matrix.drawPixel(k,h,LED_RED_HIGH);
        
      }
    }
    digitalWrite(led, 1);
    delay(1000);
    matrix.fillScreen(0);
    pinMode(led, OUTPUT);
    digitalWrite(led, 0);
    Serial.print("SETUP");
}

void loop() {
  // put your main code here, to run repeatedly:
  int n, heightx;
  n = analogRead(MIC_PIN);
  // remove the MX9614 bias of 1.25VDC
  n = abs(1023 - n); //1023
  // hard limit noise/hum
  n = (n <= NOISE) ? 0 : abs(n - NOISE);
  // apply the exponential filter to smooth the raw signal
  ADCFilter.Filter(n);
  lvl = ADCFilter.Current();


  int ySpec = map(lvl,0,140,0,15);

// *************** LED MATRIX *******************
        
        int led31 = random(ySpec);
        lightcolumns(31, ySpec+ led31);
        lightcolumns(30, ySpec+ led31);
        lightcolumns(29, 0);

        int led28 = random(ySpec);
        lightcolumns(28, ySpec+ led28);
        lightcolumns(27, ySpec+ led28);
        lightcolumns(26, 0);


        int led25 = random(ySpec);
        lightcolumns(25, ySpec + led25);
        lightcolumns(24, ySpec+ led25);
        lightcolumns(23, 0);

        int led22 = random(ySpec);
        lightcolumns(22, ySpec+ led22);
        lightcolumns(21, ySpec+ led22);
        lightcolumns(20, 0);

        int led19 = random(ySpec);
        lightcolumns(19, ySpec+ led19);
        lightcolumns(18, ySpec+ led19);
        lightcolumns(17, 0);

        int led16 = random(ySpec);
        lightcolumns(16, ySpec+ led16);
        lightcolumns(15, ySpec+ led16);
        lightcolumns(14, 0);

        int led13 = random(ySpec);
        lightcolumns(13, ySpec+ led13);
        lightcolumns(12, ySpec+ led13);
        lightcolumns(11, 0);

        int led10 = random(ySpec);
        lightcolumns(10, ySpec+ led10);
        lightcolumns(9, ySpec+ led10);
        lightcolumns(8, 0);

        int led7 = random(ySpec);
        lightcolumns(7, ySpec+ led7);
        lightcolumns(6, ySpec+ led7);
        lightcolumns(5, 0);

        int led4 = random(ySpec);
        lightcolumns(4, ySpec+ led4);
        lightcolumns(3, ySpec+ led4);
        lightcolumns(2, 0);

        int led1 = random(ySpec);
        lightcolumns(1, ySpec+ led1);
        lightcolumns(0, ySpec+ led1);
      //delay(10);
}

void lightcolumns(int rownum, int amplitude)
{
  if(amplitude >=12)  // <-O-> set the threshold for the band to turn red
  {
      for( int y = 0; y < 2; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 7));     // red-green
      }
      for( int y = 2; y <= 12; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 5, 0));     // red-green
      }
      
      
      for(int y = amplitude; y <16; y++)
      {
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 0));  
      }
      //matrix.drawPixel(rownum, amplitude+2, matrix.Color333(7, 7, 7));
  }
  
  else if(amplitude>9 && amplitude < 12 ) // <-O-> set the threshold for the band to turn yellow
  {
      for( int y = 0; y < 2; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 7));     // red-green
      }
      for( int y = 2; y < amplitude; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 5, 0));     // red-green
      }
      
      for(int y = amplitude; y < 16; y++)
      {
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 0));  
      }
      //matrix.drawPixel(rownum, amplitude+2, matrix.Color333(7, 7, 7));
  }
  
  else if(amplitude>2 && amplitude < 9) // <-O-> set the threshold for the band to turn green
  {
      for( int y = 0; y < 2; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 7));     // red-green
      }
      for( int y = 2; y < amplitude; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 5, 0));
      }
      for(int y = amplitude; y < 16; y++)
      {
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 0));  
      }
      //matrix.drawPixel(rownum, amplitude+2, matrix.Color333(7, 7, 7));
  } 
  
  else if(amplitude != 0)
  {
      for( int y = 0; y < 2; y++){
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 7));     // red-green
      }
      for(int y = amplitude; y < 16; y++)
      {
        matrix.drawPixel(rownum, y, matrix.Color333(0, 0, 0));  
      }
  } 

  if(amplitude >0 & amplitude < 16){
    matrix.drawPixel(rownum, amplitude+2, matrix.Color333(7, 7, 7));

    delay(2);
  }
  
  
}

Expansion direction


In this tutorial, Espitek uses HUB75 type led matrix board, and esp32 led scanning module is designed and separate, so it is difficult for you to find on the market.

Therefore, the purpose of this article is to introduce entertainment technology, and suggest instructions for those who want to DIY their working and studying corners to become more personal.

In addition, you can learn more led modules WS2812 and arduino. There are many tutorials to create LEDs that flash to the music much more vividly and simply.

Possible extensions:

Create a wireless audio module and send it to ESP32 to scan leds to help place music receivers anywhere in the room, cafe, etc.
Expand the led panel to “CHILL” more
Voice and sound recognition to display the message on the led board: for example, the command will display the content on the led board, etc.

NOTE: This document we are refer from: https://randomnerdtutorials.com/,if the author see this post, please we are want to share your known to our student country

Leave a Reply

Your email address will not be published. Required fields are marked *