Tuesday, May 25, 2021

Room Automation using IR Sensor

 

Automatic Light using IR Sensor

Things Required:

·         IR (Infrared) Sensor

·         5V Relay Module

·         Arduino (Uno or Nano)

·         Jumper Wires

Connections:

 


 

 

 

Code for Arduino:

int pbutton=8;

int led=3;

 

int val=0;

int ledon=0;

int pushed=0;

 

void setup()

{

  Serial.begin(9600);

  pinMode(pbutton, INPUT_PULLUP);

  pinMode(led, OUTPUT);

 

}

 

void loop()

{

  val=digitalRead(pbutton);

  if(val==HIGH && ledon==LOW)

  {

    pushed=1-pushed;

    delay(100);

  }

 

  ledon=val;

  if(pushed==HIGH)

  {

    Serial.println("led on");

    digitalWrite(led, LOW);

  }

 

  else

  {

    Serial.println("led off");

    digitalWrite(led, HIGH);

 

 

  } 

}

 

You can use this as an automatic room light.

If you are facing a problem making this, contact me at rizwanmahad606@gmail.com

Stay tuned.

Bye.

 

No comments:

Post a Comment

Scanners: Explained.

 Introduction:           If you need a copy of a document that is sitting on your table. For this, with your PC, you use your flatbed scan...