Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Bi-Directional Visitor Counter with Automatic Light Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Bi-Directional Visitor Counter with Automatic Light Control

Circuit Documentation

Summary

This circuit is designed to function as a bi-directional visitor counter with an integrated lighting control system. It utilizes an Arduino UNO as the central processing unit, interfaced with two IR sensors to detect visitor entry and exit, a 16x2 LCD display for user feedback, a single-channel 12V relay to control a bulb, and a 9V battery to power the Arduino UNO. The system counts the number of visitors inside a room and controls the lighting based on occupancy: the light turns off when the room is unoccupied.

Component List

Arduino UNO

IR Sensors (2x)

16X2 LCD

12V Single Channel Relay

Bulb

9V Battery

Wiring Details

Arduino UNO

IR Sensors

16X2 LCD

12V Single Channel Relay

Bulb

9V Battery

Documented Code

/*
  Hey Guys! Welcome to RENU ROBOTICS
  This is a Simple Project
  Bi - Directional Visitor Counter
  Hope you Like It!! 
*/

#include<LiquidCrystal.h> // Declaring the Library 

LiquidCrystal lcd(12,11,5,4,3,2); // Setting up lcd 

#define in 8  // Defining In Sensor
#define out 9 // Defining Out Sensor
#define bulb 10 //Defining Bulb(Relay)

int count = 0; // Declaring count Value

void setup()
{
  lcd.begin(16,2); // Beginning the lcd
  lcd.print("Visitor Counter"); // Printing "Visitor Counter" to the LCD
  delay(2000); // Delay of 2 seconds
  pinMode(in,INPUT); // Setting up In Sensor as INPUT 
  pinMode(out,INPUT); // Setting up Out Sensor as INPUT
  pinMode(bulb,OUTPUT); // Setting up Bulb(Relay) pin as OUTPUT  
  lcd.clear(); // Clearing/Erasing the String in LCD
  lcd.print("Person In Room:"); // Printing "Person in Room" to the LCD
  lcd.setCursor(0,1); // Setting Cursor to Print the Counting
  lcd.print(count); // Printing the Counting
}

void loop()
{  
  int in_value = digitalRead(in); // Setting Variables & Reading Values from In Sensor
  int out_value = digitalRead(out); // Setting Variables & Reading Values from Out Sensor
  
  if(in_value == LOW)
  {
    count++;
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
  }                                                        // Conditions
  
  if(out_value == LOW)
  {
    count--;
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
  }                                                        // Conditions
 
  
  if(count==0)
  {
    lcd.clear();
    digitalWrite(bulb,HIGH);
    lcd.clear();
    lcd.print("Nobody In Room");
    lcd.setCursor(0,1);
    lcd.print("Light is Off");
    delay(200);
  }                                                       // Conditions
  
  else
  {
    digitalWrite(bulb,LOW);    
  }                                                      // Conditions
}

This code is responsible for controlling the visitor counter and the lighting system. It initializes the LCD and sets up the IR sensors and relay. The loop function reads the sensor inputs to increment or decrement the visitor count and updates the LCD accordingly. It also controls the relay to turn the bulb on or off based on the room occupancy.