In this tutorial we are going to make a clap switch using a Sound Sensor & Arduino. Whenever you clap an LED will Turn On or Off. There is also a schematic below on how to use it with a relay and a light bulb.
Watch the Video!
Step 1: What You Will Need
- Arduino UNO (Or any other Arduino)
- Sound Sensor
- LED
- 1K ohm resistor
- Jumper wires
- Breadboard
- Visuino program: Download Visuino
- Optional a Relay and a light bulb
Step 2: Brought by PCBWay
Thank you PCBWay for supporting this tutorial and helping users learn more about electronics.
What I like about the PCBWay is that you can get 10 boards for approximately $5 which is really cost effective for professional made boards, not to mention how much time you save!
Go check them out here. They also offer a lot of other stuff in case you might need it like assembly, 3D printing, CNC machining and a lot more.
Step 3: The Circuit
- Connect Arduino digital pin [2] to 1K ohm resistor
- Connect 1K ohm resistor pin to LED positive pin [+]
- Connect Arduino pin [GND] to LED negative pin [-]
- Connect Arduino Analog pin [A0] to Sound Sensor pin [A0]
- Connect Arduino pin [5V] to Sound Sensor pin [VCC]
- Connect Arduino pin [GND] to Sound Sensor pin [GND]
Step 4: The Circuit Using a Relay
- Connect Relay VCC pin(+) to Arduino 5V pin
- Connect Relay GND pin(-) to Arduino GND pin
- Connect Relay signal pin(S) to Arduino Digital pin [2]
- Connect power supply 12V (+) to the Lamp positive (+)
- Connect power supply 12V (-) to the relay pin (NO)
- Connect Lamp negative (-) to relay pin(com)
Step 5: Start Visuino, and Select the Arduino UNO Board Type
The Visuino: https://www.visuino.com also needs to be installed. Download Free version or register for a Free Trial.
Start Visuino as shown in the first picture Click on the “Tools” button on the Arduino component (Picture 1) in Visuino When the dialog appears, select “Arduino UNO” as shown on Picture 2
Step 6: In Visuino Add & Set Components
- Add “Compare Analog Value” component
- Add “Detect Edge” component
- Add “Delay” component
- Add “Toggle(T) Flip-Flop” component
- Add “Digital Multi Source” component
- Select “CompareValue1” and in the properties window select “Compare Type” and set ctBigger
- Select “CompareValue1” and in the properties window select “Value” and set 0.52 <<This will be the sensitivity of the microphone, you can adjust the value from 0.50 up.
- Select “Delay1” and in the properties window set “Interval (uS)” to 10000
Step 7: In Visuino Connect Components
- Connect Arduino Analog pin [0] to “CompareValue1” pin [In]
- Connect “CompareValue1“pin [Out] to “DetectEdge1” pin [In]
- Connect “DetectEdge1“pin [Out] to “Delay1” pin [Start]
- Connect “Delay1“pin [Out] to “TFlipFlop1” pin [Clock]
- Connect “TFlipFlop1“pin [Out] to “DigitalMultiSource1” pin [In]
- Connect “DigitalMultiSource1“pin [0] to Arduino Digital pin [2]
- Connect “DigitalMultiSource1“pin [1] to “Delay1” pin [Reset]
Step 8: Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the “Build” Tab, make sure the correct port is selected, then click on the “Compile/Build and Upload” button.
Step 9: Play
If you power the Arduino module & clap the LED will turn On or Off.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Tutorial, you can download it and open it in Visuino: https://www.visuino.com
Download Clap-switch.zip