Another Audio Spectrum Analyzer.

My last project is an audio spectrum analyzer. The work has been done using a MSGEQ7 integrated. The result is shown using an 2X16 LCD display. The bars are built using defined characters.
The chip only gives 7 info of frequency. I've arrived until the 16 bar interpolating values based in the 7 given.

The music you hear is a them I wrote in 2005.

http://www.mundosimaginados.com

Well done and quite responsive,

can you share code & schematics?

That's pretty cool! You've tempted me to set one up myself some time... I know it is possible to use transistors with a resistor ladder to produce one bar of the EQ thingy (can't think of how to phrase it, so I'll draw the schematic). Do you have any codes? :smiley:

There, badly drawn and missing LED series resistors, but it should work as an EQ thingy. :slight_smile:

Onions.

I don't have an schem but you can find here info about how conect: http://nuewire.com/info-archive/msgeq7-by-j-skoba/.

And here is my code:

#include <LiquidCrystal.h>

// The LCD is conected to pins 13,12,11,10,9,8

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

byte vumetro[8][8];

float vumetros[16];

// The analog pin 0 is used to read value.
int valor_analogico = 0; 
// The 6 & 7 pins are used for control the integrated.
int strobe = 6; 
int reset = 7; 
int valores_frecuencias[7]; 

void setup() {
  // Built the characters for bars.
  for (int j=0; j<=7; j++)  
  {
    for (int i=0; i<=7; i++)
    {
      if (i<=j)
      { vumetro[j][7-i] = B01110;}
//      { vumetro[j][7-i] = B01010;}  Uncomment this lines for getting other variants for bars.
//      { vumetro[j][7-i] = B11111;}      
      else
      { vumetro[j][7-i] = 0;}
    }
  }  
  for (int i=0; i<=7;i++)
  {
    lcd.createChar(i, vumetro[i]);
  }

  lcd.begin(16, 2);      
  for (int j=0; j<=7;j++)
  {
    lcd.setCursor(j, 0);
    lcd.write(j);
    lcd.setCursor(j, 1);
    lcd.write(7);    
    
  pinMode(valor_analogico, INPUT);
  pinMode(strobe, OUTPUT);
  pinMode(reset, OUTPUT);
  analogReference(DEFAULT);

  digitalWrite(reset, LOW);
  digitalWrite(strobe, HIGH);
    
  }  
 
}

void loop() {
  
  digitalWrite(reset, HIGH);
  digitalWrite(reset, LOW);

  // The read of integrated is done by multiplexing.
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobe, LOW);
    delayMicroseconds(5); 
    valores_frecuencias[i] = analogRead(valor_analogico);
    digitalWrite(strobe, HIGH);
  }

// It's necesary to interpolate for calculating 16 bars having only 7 values read.
for (int k=0; k<=15; k++)
  {
  switch (k) 
  {
    case 0:
      vumetros[k]= valores_frecuencias[0]/64;
      break;
    
    case 1:
      vumetros[k]= (valores_frecuencias[0]/64 + valores_frecuencias[1]/64)/2;
      break;

    case 2:
      vumetros[k]= valores_frecuencias[1]/64;
      break;
   
    case 3:
      vumetros[k]= (valores_frecuencias[1]/64 + valores_frecuencias[2]/64)/2;
      break;
 
    case 4:
      vumetros[k]= valores_frecuencias[2]/64;
      break;
    
    case 5:
      vumetros[k]= (valores_frecuencias[1]/64 + valores_frecuencias[2]/64 + valores_frecuencias[3]/64)/3;
      break;
        
    case 6:
      vumetros[k]= (valores_frecuencias[2]/64 + valores_frecuencias[3]/64 + valores_frecuencias[4]/64)/3;
      break;

    case 7:
      vumetros[k]= random(2)+valores_frecuencias[3]/64;
      break;
      

    case 8:
      vumetros[k]= random(2)+valores_frecuencias[3]/64;
      break;

    case 9:
      vumetros[k]= (valores_frecuencias[2]/64 + valores_frecuencias[3]/64 + valores_frecuencias[4]/64)/3;
      break;

    case 10:
      vumetros[k]= (valores_frecuencias[3]/64 + valores_frecuencias[4]/64 + valores_frecuencias[5]/64)/3;
      break;

    case 11:
      vumetros[k]= valores_frecuencias[4]/64;
      break;

    case 12:
      vumetros[k]= (valores_frecuencias[4]/64 + valores_frecuencias[5]/64)/2;
      break;

    case 13:
      vumetros[k]= valores_frecuencias[5]/64;
      break;

    case 14:
      vumetros[k]= (valores_frecuencias[5]/64 + valores_frecuencias[6]/64)/2;
      break;

    case 15:
      vumetros[k]= valores_frecuencias[6]/64;
      break;
  }

  Dibuja_vumetro(k, vumetros[k]);
  delay(2);
  }
  
}

void Dibuja_vumetro(int posicion, int altura)
{
  if (altura>7)
  {
    lcd.setCursor(posicion, 1);
    lcd.write(7);
    lcd.setCursor(posicion, 0);
    lcd.write(altura-8);    
  }
  else
  {
    lcd.setCursor(posicion, 1);
    lcd.write(altura);
    lcd.setCursor(posicion, 0);
    lcd.write(32);    
  }
}

Very cool!

I really am glad I had a copy of J Skoba's tutorial saved (for my own benefit) and now since I reposted it even happier to see others benefit as well.

willnue

Thanks you for posting the tutorial. I decided to start my develop seeing the post you saved...

http://fritzing.org/projects/msgeq7-audio-equalizer/
http://fritzing.org/projects/sparkfun-spectrum-shield-audio-equalizer-lcd/

Have create on this Thread and http://nuewire.com/info-archive/msgeq7-by-j-skoba/