LED and Sound Detector

Hello all,

I am brand new to Arduino and want to do a project where LED lights react to a knocking sound. I have the sound detector hooked up to an LED light and the code to make the light turn on every time it detects a sound and turn off when it detects a sound again. WHat i want to do is have a series of LED lights turn on one at a time as the knocking progresses instead of turning off. I'm not sure how to write the code for this so some guidance would be greatly appreciated!

  • ALeja :grin:

Let's say you have a variable num.
Each time you detect a sound increment num.
If num > 0 turn on led0
If num > 1 turn on led1
If num > 2 turn on led2
.
.
.
If num > 5 turn all leds off and make num = 0

Have fun!

Thanks for the reply! Would i just type that in to the code exactly how you did?

No, you have to use proper Arduino C++ syntax.
Sounds like you need to go through the basic examples that come with the Arduino IDE to get some programming experience.