Clap to Turn On The Light!


When I was young, I always have this kind of thought “Can I just switch off the light when I was about to sleep on the bed without going to the switch and turn it off?”. (I’m a bit scared when I sleep alone without my sibling) Hihi.. Then today, I found out that it’s actually doable to turn on and off the light by clapping my hand. Now, let’s have a look on how to do it! 


This is the video for this project.


This tutorial use :

  1. Maker UNO
  2. Mini Microphone Module (Sound Sensor)
  3. Yellow LED
  4. 220 ohm Resistor
  5. Male to Male Jumper Wire
  6. Breadboard
  7. Micro B USB

You can make the hardware connection based on the diagram and table below.

Sound Sensor : VCCMaker UNO: 5V
Sound Sensor : GNDMaker UNO: GND
Sound Sensor : OutMaker UNO: pin 10
Yellow LED (+)Maker UNO: pin 4
Yellow LED (-)Maker UNO: GND with Resistor
Figure 1 : Hardware Connection
Figure 2 : The Sound Sensor Connection


This is the sample code used for this tutorial. Try it!

  This example code is for Clap to Turn On The Light's Tutorial.
  Product page:
  Maker UNO:
  Sound Sensor :
  Created by:
  24/07/18  Suad Anwar, Cytron Technologies

int SoundSensor = 10;
int yellow = 4;
int value = 0;
int flag = 0;

void setup() {
  pinMode(yellow, OUTPUT);
  pinMode(SoundSensor, INPUT);

void loop() {
  value = digitalRead(SoundSensor); // To get the Sound Sensor's value

  if (value == 1) {

    if (flag == 1) {
      digitalWrite(yellow, HIGH);
      flag = 0;

    else if (flag == 0) {
      digitalWrite(yellow, LOW);
      flag = 1;

The Museum

This is the template for the paper house. Kindly download it here. You can always check another house and building here.

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

8 thoughts on “Clap to Turn On The Light!”

  1. Hi Piyal, value is the state of the sensor. Seems both turn on and off using the same method (one clap), we used flag variable to toggle it. Thanks.

  2. Is it possible instead of using arduino, I used raspberry Pi 2? If can, may I get the semantic diagram and code used for raspberry pi.Thank you.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
TinyML on Arduino using Edge Impulse
Tutorials of Cytron Technologies Scroll to Top