//Visitors Counter and Automatic Room Light
#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++;
lcd.clear();
lcd.print ("Person In Room: ");
lcd.setCursor (0,1);
lcd.print (count);
delay(1000);
}
void OUT ()
{
count--;
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);
}


Steps :
- The objective of this project is to make a controller based model to count number of persons visiting particular room and accordingly light up the room. Here we can use sensor and can know present number of persons.
- The total number of person inside the room also displayed on the seven segment displays.
- The microcontroller receives the signals from the sencers, and this signal is operated under the control of software which is stored in rom.
This Project ―Automatic Room Light Controller with Visitor Counter using Microcontroller is a reliable circuit that takes over the task of controlling the room lights as well us counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays.
The microcontroller does the above job.
It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller (Arduino) continuously monitor the Infrared Receivers, When any object pass through the IR Receiver's then the IR Rays falling on the receiver are obstructed , this obstruction is sensed by the Microcontroller.
1. Optimized Energy Consumption : By automatically adjusting lighting based on real-time occupancy data, this system significantly reduces energy waste, leading to substantial electricity savings.
2. Efficient Space Utilization : Accurate bidirectional counting ensures efficient space utilization, allowing for better resource allocation and improved user experience.