Amrendra0110
Published © Apache-2.0

Automatic Room Light Controller with Bidirectional Visitor

When at least one person enters the room, the light and fan turn ON. When everyone exits the room, the light turns OFF.

BeginnerShowcase (no instructions)30 minutes23,612
Automatic Room Light Controller with Bidirectional Visitor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Relay (generic)
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Infrared Module
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Circuit Digram

Code

Source code

Arduino
#include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
#define in 14
#define out 19
#define relay 2
int count=0;
void IN()
{
    count++;
    if(count>=10)
    {
      count=10;
      }
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
}
void OUT()
{
    count--;
    if(count<=0)
    {
      count=0;
      }
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
}
void setup()
{
  lcd.begin(16,2);
  lcd.print("Visitor Counter");
  delay(2000);
  pinMode(in, INPUT);
  pinMode(out, INPUT);
  pinMode(relay, OUTPUT);
  lcd.clear();
  lcd.print("Person In Room:");
  lcd.setCursor(0,1);
  lcd.print(count);
}
void loop()
{  
  
  if(digitalRead(in))
  IN();
  if(digitalRead(out))
  OUT();
  
  if(count<=0)
  {
    lcd.clear();
    digitalWrite(relay, LOW);
    lcd.clear();
    lcd.print("Nobody In Room");
    lcd.setCursor(0,1);
    lcd.print("Light Is Off");
    delay(200);
  }
  
  else
    digitalWrite(relay, HIGH);
  
}

Credits

Amrendra0110
2 projects • 5 followers
Contact

Comments

Please log in or sign up to comment.