Posts

Showing posts from August, 2023

Arduino Code

 #define SENSOR_PIN 2 #define RELAY_PIN 3 int previousValue = HIGH; int clapCount = 0; unsigned long previousTime = millis(); bool relayOutPut = HIGH; void setup()  {   pinMode(SENSOR_PIN , INPUT);   pinMode(RELAY_PIN, OUTPUT);   //Turn off relay . Relay is LOW level triggered relay   digitalWrite(RELAY_PIN, HIGH); } void loop()  {   int currentValue = digitalRead(SENSOR_PIN);   if (previousValue == HIGH && currentValue == LOW)   {     if (clapCount == 1 &&  millis() - previousTime >= 500)     {       clapCount = 0;     }          if (clapCount == 0)     {       previousTime = millis();     }     clapCount++;     if (clapCount == 2)     {       relayOutPut = !relayOutPut;       digitalWrite(RELAY_PIN, relayOutPut);       clapCount = 0;               }     delay(200);       }   previousValue = currentValue; }

Circuit Diagram

Image
 

Materials Required

 Arduino UNO:- https://amzn.to/3mhamzG Jumper Wires:- https://amzn.to/3GvV1SW 5V Relay:- https://amzn.to/447ZpAs Sound Sensor:- https://amzn.to/3YFZASc

Sequential LED Circuit Diagram

Image
 

Materials Required

Image
  Arduino UNO:- https://amzn.to/3mhamzG IR Sensor:- https://amzn.to/3Kjn6P6 Jumper wires:- https://amzn.to/3QD436z Red LED:- https://amzn.to/44Oh29D

IR Sensor Arduino Code

Image
  void setup() {   pinMode(13,OUTPUT);   pinMode(2,INPUT); } void loop() {   if (digitalRead(2)==HIGH)   {     digitalWrite(13,LOW);     }   else    {     digitalWrite(13,HIGH);   }  } 

IR Sensor circuit diagram

Image