DIY Motion-Activated Relay Control using Arduino

Welcome to our Arduino project series! In this tutorial, we'll guide you through the process of creating a Clap Switch using an Arduino, a sound sensor, and a relay module. This interactive project allows you to control electronic devices with the simple gesture of clapping your hands.
Before we dive into the project, let's gather the necessary components:
Let's start by connecting the components to build the circuit:
Sound Sensor to Arduino:
Relay Module to Arduino:
Connect the Electronic Device to the Relay Module:
Now, let's upload the Arduino code to make it all work:
const int soundSensorPin = 2;
const int relayPin = 7;
void setup() {
pinMode(soundSensorPin, INPUT);
pinMode(relayPin, OUTPUT);
}
void loop() {
int soundValue = digitalRead(soundSensorPin);
if (soundValue == HIGH) {
// Clap detected, toggle the relay state
digitalWrite(relayPin, !digitalRead(relayPin));
delay(1000); // Add a delay to prevent multiple toggles from a single clap
}
}
Congratulations! You've successfully built a Clap Switch using Arduino. This project not only provides a hands-on experience with electronics but also opens the door to more exciting Arduino projects. Stay tuned for more tutorials in our Arduino project series!
If any project requirement Contact me on +918973147676 Thank you.
Comments
Post a Comment