Clap Switch Using Sound Sensor & Arduino

by RonFrtek in Circuits > Arduino

117 Views, 1 Favorites, 0 Comments

Clap Switch Using Sound Sensor & Arduino

Clap Switch Using Sound Sensor & Arduino

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!

What You Will Need

arduino-microphone-ky037.jpg
LED-RED.png
resistor-1k-ohm-14w-5.jpg
FZEK4WBK3XGYAP0.LARGE.jpg
VisuinoAdvrtisementPLCXPertTinyLab (1).jpg
breadboard.png
9839_s.jpg
1-relay-module-for-arduino.jpg
  • 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


Brought by PCBWay

2022-08-26_13-41-18.jpg

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 assembly3D printingCNC machining and a lot more.

The Circuit

2022-09-24_12-38-50.jpg
  • 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]

The Circuit Using a Relay

2022-09-23_10-40-28.jpg


  • 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)


Start Visuino, and Select the Arduino UNO Board Type

FRWQB80K1RVKKV9.LARGE.jpg
Visuino-Select-Board-UNO.jpg

The Visuino: https://www.visuino.eu 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

In Visuino Add & Set Components

2022-09-24_13-23-42.jpg
2022-09-24_13-24-06.jpg
2022-09-24_13-24-28.jpg
2022-09-24_13-24-54.jpg
2022-09-24_13-25-23.jpg
2022-09-24_13-26-31.jpg
2022-09-24_13-26-03.jpg
  • 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

In Visuino Connect Components

2022-09-24_13-31-59.jpg
2022-09-24_13-32-15.jpg
  • 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]

Generate, Compile, and Upload the Arduino Code

2020-10-30_13-20-50.jpg

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.

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.eu