PostsWifi

Turning on the lights with a clap

This is a basic module for turning on or off the light with a clap. I will be using an LED for this demonstration to keep it simple, but it works the same with a normal light bulb if you want that. This module isn’t a viable product though, as it will pick up all the sounds that have a high frequency, but it does work for this purpose . I used an Arduino Uno, but you are free to use any microcontrollers you like, no restrictions there, just make sure that it can read analog inputs, and make sure to map to the correct pins.

Hardware

The led needs an 220 ohm resistor
1 X Microcontroller

1 X Microphone/Sensor

1 X LED

Schematics

Microphone:

GND GND
5V Vcc
DO pin 11

LED:

GND GND
5V pin 7

schema:

Source Code


int soundSensor = 11;
int LED = 7;
boolean LEDStatus = false;

void setup() {
pinMode(soundSensor, INPUT);
pinMode(LED, OUTPUT);

}

void loop() {

int SensorData = digitalRead(soundSensor);
if (SensorData == 1) {

if (LEDStatus == false) {
LEDStatus = true;
digitalWrite(LED, HIGH);
}
else {
LEDStatus = false;
digitalWrite(LED, LOW);
}
}
}

Related posts
IntegrationPostsThe Things Network

How we integrated an external service to RTW using Webhooks and PhP

PostsWifi

Code used to connect to WIFI with Esp32 (Referenced as WifiCode)

PostsWifi

Automatic trash can opener based on distance

PostsWifi

Automatic adjust brightness according to how bright the environment is

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *