So this project is perfect for beginners because the coding is very simple and easy to understand. In addition, the sensor used, namely KY-037, is also very affordable.
So the way it works is when the KY-037 sound sensor detects a high frequency (clapping sound) then the sensor will output HIGH.
The HIGH output that will be processed by the coding that we have made turns on or off (depending on the condition of the lamp)
If the light is off, when we clap our hands near the KY - 037 sensor, the light will turn on. However, if the lights are on, when we clap our hands near the KY - 037 sensor, the lights will turn off.
So basically this project is perfect for people who are just learning about electronics, especially Arduino.
Tools and Materials
- Arduino Nano
- 5 Volt LED
- KY-037 sensor
- Jumper Cables
- Bread Board
Pin Configuration
KY-037 sensor
- OUTPUT = PIN Arduino D2
- INPUT = 5V Arduino
- GND = GND Arduino
Note :
- The output in this circuit we use the digital sensor pin (D0).OUTPUT is a component that will be controlled by Arduino based on a program written in the Arduino IDE application.
- This INPUT is the signal generated from the sensor measurement. Because we are using the Digital pin (D0) there are only two types of signals, namely HIGH / LOW.
- HIGH means the sound sensor is detecting high frequency waves.LOW means the sound sensor is not detecting high frequencies.
- The INPUT will be processed by Arduino into an LED light with a specific coding that has been written.
LED
- LED Positive Pin (the longer one) : connects to the Arduino D3 pin
- LED Negative Pin (the shorter one) : connects to the Arduino GND pin
How Circuits WorkBasically the way this circuit works is very simple:
- Sound Sensor KY-037 will measure the sound waves received by the sensor.
- The measurement results will be converted into electrical quantities.
- Because we are using a Digital (DO) pin, the amount of electricity is a HIGH / LOW signal.
- This HIGH / LOW output is what we will then use to turn on the LED and turn off the LED.
- If OUTPUT HIGH then the LED will change condition, either from on to off or off to on.
- A HIGH output will be created due to high frequency sounds (from loud applause plaque).
Code :
//Controlling lamp with Clapping Sound
// By Syakir Daulay
int soundSensor = 2;
int pinLED = 3;
boolean condition = 0;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pinLED, OUTPUT);
pinMode(soundSensor, INPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
int sensorValue = digitalRead(soundSensor);
if (sensorValue == HIGH)
{
condition = !condition;
digitalWrite(pinLED, condition);
Serial.print ("There is High Frekuensi Sound");
}
delay (1000);
}
Comments
Please log in or sign up to comment.