Archive | Arduino

Arduino Color Organ

The Color Organ used the MSGEQ7 graphic equalizer chip. Information on using it came from http://nuewire.com/info-archive/msgeq7-by-j-skoba/

I found that rather than blast the output values to the LED’s, it would be better to set ranges of values and light up the LED’s from that range.


int analogPin = 0; // read from multiplexer using analog input 0
int strobePin = 2; // strobe is attached to digital pin 2
int resetPin = 4; // reset is attached to digital pin 4
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);

}

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);

if (spectrumValue[i] < 65) {
analogWrite(pwm[i], 1023);
Serial.print(” “);
Serial.print(“0”);
} else if (spectrumValue[i] < 80) {
analogWrite(pwm[i], 1022);
Serial.print(” “);
Serial.print(“1”);
} else if (spectrumValue[i] < 100) {
analogWrite(pwm[i], 1021);
Serial.print(” “);
Serial.print(“2”);
} else if (spectrumValue[i] < 200) {
analogWrite(pwm[i], 1020);
Serial.print(” “);
Serial.print(“3”);
} else {
analogWrite(pwm[i], 1015);
Serial.print(” “);
Serial.print(“4”);
}

}
digitalWrite(strobePin, HIGH);
Serial.println();
}

Continue Reading