Code And Circuit Diagram For Controlling Room Lights With A Clap





int micPin = A0;
int gndPin = A1;
int powerPin = A2;
int micValue1 = 0;
int micValue2 = 0;
int led1 = 13;
boolean lightOn = false;

 

void setup() {
pinMode(led1, OUTPUT);
pinMode(powerPin, OUTPUT);
pinMode(gndPin, OUTPUT);
pinMode(micPin, INPUT);
digitalWrite(gndPin,LOW);
delay(500);
digitalWrite(powerPin,HIGH);
Serial.begin(9600);
}

void loop() {
micValue1 = analogRead(micPin);
Serial.println(micValue1);
delay(1);
micValue2 = analogRead(micPin);
Serial.println(micValue2);

if (micValue1-micValue2 > 2||micValue2-micValue1 > 2){
lightOn = !lightOn;
delay(100);
digitalWrite(led1, lightOn);
}
}

 

IF YOU ARE GETTING A STRAY ERROR CLICK HERE



8 Comments on “Code And Circuit Diagram For Controlling Room Lights With A Clap”

  1. Hi there,
    bro where is the circuit diagram? There is no link for the circuit diagram and what about the android app you used? How to get that app?

Leave a Reply

Your email address will not be published. Required fields are marked *