Clap Switch Using Sound Sensor & Arduino

About the project

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.

Project info

Difficulty: Easy

Platforms: ArduinoSparkFunVisuino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Breadboard (generic) Breadboard (generic) x 1
Jumper wires (generic) Jumper wires (generic) x 1
Resistor 1k ohm Resistor 1k ohm x 1
LED (generic) LED (generic) x 1
SparkFun Electret Microphone Breakout SparkFun Electret Microphone Breakout x 1

Software apps and online services

Visuino Visuino
Arduino Web Editor Arduino Web Editor
Arduino IDE Arduino IDE


Step 1: What You Will Need

1 / 6

  • 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 assembly3D printingCNC 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

1 / 2

The Visuino: 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

1 / 8

  • 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

1 / 2

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

Schematics, diagrams and documents

Visuino file


Visuino File


Photo of Ron


Arduino Developer


Leave your feedback...