Hi! I am very new to Arduino and coding. So a lot of this is pretty confusing. But, I have a Digital sandbox and I want to make it so that the RGB LED reacts to different levels of sound. I am having trouble because I can't find out how to make this happen, and the slider is making things weird I think. I have it to when I snap it lights up, but I want the lights to be more "bouncy" if that makes sense. I will copy my code below. thanks so much!
// Sandbox 13: Sound Detecting
const int slidePin = A3;
const int micPin = A2;
const int ledPins[5] = {4, 5, 6, 7, 8};
const int colorPin[3] = {9, 10, 11};
void setup()
{
pinMode(slidePin, INPUT);
pinMode(micPin, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
for (int i = 0; i < 5; i++)
{
pinMode(ledPins*, OUTPUT);*
- }*
}
void loop()
{ - int maximum = analogRead(slidePin);*
- int micReading = analogRead(micPin);*
- int medium = maximum / 2;*
- int minimum = 0;*
- for (int i = 0; i < 5; i++) {*
_ if (micReading > ((maximum / 5) * (i + 1))) {_
_ digitalWrite(ledPins*, HIGH);_
_ //checkMicLevel(micReading, maximum);_
_ }_
_ else*_
* {*
* // Otherwise, turn off that LED*
_ digitalWrite(ledPins*, LOW);
}
}
if (micReading == maximum ){
digitalWrite(9, LOW);
}
if(micReading != maximum){
digitalWrite(9, HIGH);
}
if (micReading == minimum ){
digitalWrite(11, LOW);
}
if(micReading != minimum){
digitalWrite(11, HIGH);
}*_
}
void checkMicLevel(int micReading, int maximum){
}