Introduction: Arduino Controlled LED Music Light Show by Mark
Materials (Pictured):
Arduino Uno
Soldering Iron
Male to Male Pins
Headphone Cable (Audio Cable)
Materials (Not Pictured):
Breadboard
Single LED Lights
Resistors
Step 1: Solder You Spectrum Shield to Pin Headers
Because of my lack of stackable pin headers, I had to solder my Spectrum Shield onto a dud board.
Step 2: Attached the Spectrum Shield to the Uno
Step 3: Wiring
Step 4: Code
// *** Initializing the Spectrum Shield pins and the reading the frequency from SparkFun *** \\
// https://learn.sparkfun.com/tutorials/spectrum-shi...
// Mark
#define STROBE 4
#define RESET 6
#define DC_One A0
#define DC_Two A1
#define LED_LIGHT_TREBLE 9
#define LED_LIGHT_MID 8
#define LED_LIGHT_BASS 7
int LEDLights[] = {7,8,9};
int frequenciesOne[7];
int frequenciesTwo[7];
void setup() {
Serial.begin(9600);
pinMode(STROBE, OUTPUT);
pinMode(RESET, OUTPUT);
pinMode(DC_One, INPUT);
pinMode(DC_Two, INPUT);
digitalWrite(STROBE, HIGH);
digitalWrite(RESET, HIGH);
pinMode(LED_LIGHT_TREBLE, OUTPUT);
pinMode(LED_LIGHT_MID, OUTPUT);
pinMode(LED_LIGHT_BASS, OUTPUT);
digitalWrite(STROBE, LOW); delay(1);
digitalWrite(RESET, HIGH); delay(1);
digitalWrite(STROBE, HIGH); delay(1);
digitalWrite(STROBE, LOW); delay(1);
digitalWrite(RESET, LOW);
}
//this function will make the LED dim once the Parallax Sound Impact Sensor sends a 1 signal, and then return to it’s //original brightness.
void loop() {
Read_Frequencies();
Graph_Frequencies();
delay(50);
}
/*************Pull frquencies from Spectrum Shield****************/
void Read_Frequencies() {
//Read frequencies for each band
for (int freqAmp = 0; freqAmp < 7; freqAmp++) {
frequenciesOne[freqAmp] = analogRead(DC_One);
frequenciesTwo[freqAmp] = analogRead(DC_Two);
digitalWrite(STROBE, HIGH);
digitalWrite(STROBE, LOW);
}
}
void Graph_Frequencies() {
int theDelay = 20;
int bassThreshold = 150;
int midThreshold = 200;
int trebleThreshold = 200;
for(int i = 0; i < 7; i++) {
if (i == 0) {
if (frequenciesTwo[i] > bassThreshold) {
digitalWrite(LEDLights[0], HIGH);
} else if (frequenciesOne[i] > bassThreshold) {
digitalWrite(LEDLights[0], HIGH);
} else {
digitalWrite(LEDLights[0], LOW);
}
delay(theDelay);
digitalWrite(LEDLights[0], LOW);
}
if (i == 3) {
if (frequenciesTwo[i] > midThreshold) {
digitalWrite(LEDLights[1], HIGH);
} else if(frequenciesOne[i] > midThreshold) {
digitalWrite(LEDLights[1], HIGH);
} else {
digitalWrite(LEDLights[1], LOW);
}
delay(theDelay);
digitalWrite(LEDLights[1], LOW);
}
if (i == 6) {
if(frequenciesTwo[i] > trebleThreshold) {
digitalWrite(LEDLights[2], HIGH);
} else if(frequenciesOne[i] > trebleThreshold) {
digitalWrite(LEDLights[2], HIGH);
} else {
digitalWrite(LEDLights[2], LOW);
}
delay(theDelay);
digitalWrite(LEDLights[2], LOW);
}
}
}