Hello Forum,
I'm currently working on a project at my university and I'm new to the Arduino-World. We want to build a facade-prototype that reacts to sound frequencies.
I use the Arduino UNO and Sparkfun's FrequencySpectrum Shield.
To test the Spectrum Shield, I have build a basic LED setup from this spectrum-shield-hookup-guide.
Now my problem: The three midrange frequencie LED's are not turning OFF. When I try and turn off the music, the LED's remain ON. They blink slightly and dimm down when i turn off the music but ultimately they don't turn OFF. The low- and high- frequency LED's work propperly.
Is there something wrong with my code?
Is there something wrong with my setup?
Here is the code I use:
/********* Definieren der SpectrumShield connections zu UNO *********/
#define STROBE 4
#define RESET 5
#define DC_One A0
#define DC_Two A1
/********* Definieren der Arduino connections. Hier die Servo Ausgänge *********/
int LED[] = {7, 8, 9, 10, 11, 12, 13};
/********* Definieren der Spectrum Variablen *********/
int freq_amp;
int Frequencies_One[7];
int Frequencies_Two[7];
int i;
/********************Setup Loop*************************/
void setup() {
//Set LED pin configurations
for(i=0; i<7; i++)
{
pinMode(LED[i], OUTPUT);
digitalWrite(LED[i], LOW);
}
//Set spectrum Shield pin configurations
pinMode(STROBE, OUTPUT);
pinMode(RESET, OUTPUT);
pinMode(DC_One, INPUT);
pinMode(DC_Two, INPUT);
digitalWrite(STROBE, HIGH);
digitalWrite(RESET, HIGH);
//Initialize Spectrum Analyzers
digitalWrite(STROBE, LOW);
delay(1);
digitalWrite(RESET, HIGH);
delay(1);
digitalWrite(STROBE, HIGH);
delay(1);
digitalWrite(STROBE, LOW);
delay(1);
digitalWrite(RESET, LOW);
}
/****************Main Function Loop***************************/
void loop() {
Read_Frequencies();
Graph_Frequencies();
delay(50);
}
/*************Pull frquencies from Spectrum Shield****************/
void Read_Frequencies(){
//Read frequencies for each band
for (freq_amp = 0; freq_amp<7; freq_amp++)
{
Frequencies_One[freq_amp] = analogRead(DC_One);
Frequencies_Two[freq_amp] = analogRead(DC_Two);
digitalWrite(STROBE, HIGH);
digitalWrite(STROBE, LOW);
}
}
/***************Light LEDs based on frequencies******************/
void Graph_Frequencies(){
for( i= 0; i<7; i++)
{
if(Frequencies_Two[i] > Frequencies_One[i]){
analogWrite(LED[i], Frequencies_Two[i]/4);
}
else{
analogWrite(LED[i], Frequencies_One[i]/4);
}
}
}
The final plan is to break the 7 frequencies into 3 frequencies that each run a servo.
Please help me out on this. I just started and directly have my first problem
Attached is a photo of my setup. (I havent soldered anything yet, so please ignore the cables i used to connect the shield with the Arduino xD)