Introduction: Clap-activated LED Array
By the end of this instructable you will be able to build a device that listens to loud noises like claps and responds to them by turning on or off 3 LEDs. Above is an image of the final result.
Step 1: Materials
Step 2: Assembly
Wire the Arduino and its components up like it is in this diagram. The blue and grey wires represent male-male jumper cables and the yellow, black and red wires represent male-female jumper cables.
Note that you are also able to fit the circuit onto a mini breadboard like I did in the step 1 image. I wouldn't recommend it though, as it's really easy to mix up or break things when they are packed tightly together.
Since I couldn't find a part for the KY-038, I had to leave it out of the diagram. The yellow wire should be connected to its "A0" pin, the black wire should be connected to its "G" (Ground) pin, and the red wire should be connected to its "+" (5V) pin.
Step 3: Code
Open up the Arduino IDE and paste the following code into it:
Change lines 1 to 25 if needed; I have added comments to explain what each of the constants do.
After you have pasted and modified the code to your liking, upload it to the Arduino.
Step 4: Done!
If everything goes according to plan, you should have a fully functional clap-activated LED array. Here are a list of commands in my current code:
- 2 claps: Toggles LED 1
- 3 claps: Toggles LED 2
- 4 claps: Toggles LED 3
- 5 claps: Turns all LEDs off
- 6 claps: Turns all LEDs on
- 16 claps: Light show! :P
If you are brave enough, you can go into my code and add or modify the current commands to do different things. The relevant code is on lines 84-148.