Your shopping cart is empty!
Clap to Turn On The Light!
INTRODUCTION
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!
VIDEO
This is the video for this project.
HARDWARE PREPARATION
This tutorial use :
- Maker UNO
- Mini Microphone Module (Sound Sensor)
- Yellow LED
- 220 ohm Resistor
- Male to Male Jumper Wire
- Breadboard
- Micro B USB
You can make the hardware connection based on the diagram and table below.
Connection | |
---|---|
Sound Sensor : VCC | Maker UNO: 5V |
Sound Sensor : GND | Maker UNO: GND |
Sound Sensor : Out | Maker UNO: pin 10 |
Yellow LED (+) | Maker UNO: pin 4 |
Yellow LED (-) | Maker UNO: GND with Resistor |
SAMPLE CODE
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: p-maker-uno
Sound Sensor : p-so-mic-mod
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;
}
delay(200);
}
}
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.