HeathenHacks
Published © GPL3+

Arduino Project#6 [The Sequel to Project #5]

As the title says, this is just a sequel to my Project#5

IntermediateShowcase (no instructions)711
Arduino Project#6 [The Sequel to Project #5]

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DFRobot MSGEQ7 Audio Analyzer Module
×1
LED (generic)
LED (generic)
I used 3mm whites and blues.
×90
Resistor 100 ohm
Resistor 100 ohm
×9

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Prototype PCB

Story

Read more

Schematics

dfr01263_PlF9bd9NIn.png

Code

My edited code.

Arduino
#include <AudioAnalyzer.h>

#define msgRST 12
#define msgStrobe 13
#define msgAnalog 0
Analyzer Audio = Analyzer(10, 11, 0); //Strobe pin ->10  RST pin ->11 Analog Pin ->0


int LEDpins[7] = {2, 3, 4, 5, 6, 7, 8};
int FreqVal[7] = {63, 160, 400, 1000, 2500, 6250, 16000};

void setup()
{
  Serial.begin(57600);	//Init the baudrate
  Audio.Init();         //Init module

  for (int x = 0; x < 7; x++) {
    pinMode(LEDpins[x], OUTPUT);
  }
  pinMode(msgRST, OUTPUT);
  pinMode(msgStrobe, OUTPUT);
}


void loop()
{
  Audio.ReadFreq(FreqVal);      //return 7 value of 7 bands pass filter
  //Frequency(Hz):63  160  400  1K  2.5K  6.25K  16K
  //FreqVal[7]:      0    1    2    3    4    5    6
  digitalWrite(msgRST, HIGH);
  delay(20);
  digitalWrite(msgRST, LOW);

  for (int x = 0; x < 7; x++)
  {
    digitalWrite(msgStrobe, LOW);
    delayMicroseconds(20);
    int spectrumRead = analogRead(0);
    int PWMvalue = map(spectrumRead, 0, 1024, 0, 255);
    if (PWMvalue < 75)
      PWMvalue = PWMvalue / 100;
    analogWrite(LEDpins[x], PWMvalue);
    digitalWrite(msgStrobe, HIGH);

    
    Serial.print(max((FreqVal[x] - 100), 0));     //Transmit the DC value of the seven bands
    if (x < 6)  Serial.print(",");
    else Serial.println();
  }



}

Credits

HeathenHacks

HeathenHacks

24 projects • 57 followers
I don't know what I'm doing here.

Comments