#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
int analogPin = 1; // read from multiplexer using analog input 0
int strobePin = 11; // strobe is attached to digital pin 2
int resetPin = 10; // reset is attached to digital pin 3
int spectrumValue[7]; // to hold a2d values
void setup()
{
Serial.begin(9600);
pinMode(analogPin, INPUT);
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
analogReference(DEFAULT);
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
lcd.begin(16, 2);
}
void loop()
{
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
for (int i = 0; i < 7; i++)
{
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // to allow the output to settle
spectrumValue[i] = analogRead(analogPin);
// comment out/remove the serial stuff to go faster
// - its just here for show
if (spectrumValue[i] < 60)
{
Serial.print(" ");
Serial.print(spectrumValue[i]);
}
else if (spectrumValue[i] < 300 )
{
Serial.print(" ");
Serial.print(spectrumValue[i]);
// lcd.print(i);
// lcd.print(" ");
}
else
{
Serial.print(" ");
Serial.print(spectrumValue[i]);
}
//LCD
if (spectrumValue[0] > 300) {
lcd.clear();
lcd.print("Bass is high");
}
else if (spectrumValue[2] > 300 )
{
lcd.clear();
lcd.print("Midrange is high");
}
else if (spectrumValue[3] > 300 )
{
lcd.clear();
lcd.print("Midrange is high");
}
else if (spectrumValue[4] > 300 )
{
lcd.clear();
lcd.print("High mids are high");
}
else if (spectrumValue[5] > 300 )
{
lcd.clear();
lcd.print("Experiencing High Frequencies");
}
else if (spectrumValue[6] > 300 )
{
lcd.clear();
lcd.print("HIGH FREQUENCIES WOW");
}
else {
lcd.clear();
}
digitalWrite(strobePin, HIGH);
}
Serial.println();
}