This person counter uses infrared sensors for counting persons passing through. This project is useful for lecture rooms and conference hall where it can count the number of persons inside the hall. The logic turns on the light if there is a person inside the room else if the person count is zero lights remain off. The demonstration is made for room lights only but the application can be extended for security applications.
The hardware consists of following parts:
Arduino Board
Liquid Crystal Display 16×2
IR Photo diode pair
Relay or Transistor for switching In addition a LDR is connected to analog read pin A0 that turn ON the lawn lights when there is dark outside. LDR should always be place far from light to be operated to avoid a self triggering loop.
Connections:
Construction:
Code:
#include <LiquidCrystal.h> #define in 8 #define out 9 #define relay 10 #define led 11 int count =0; LiquidCrystal lcd(2, 3,4,5, 6,7); void IN() { count++; lcd.clear(); lcd.print("Persons Inside :"); lcd.setCursor(0,1); lcd.print(count); delay(500); } void OUT() { if(count>=1) { count--;} lcd.clear(); lcd.print("Persons Inside :"); lcd.setCursor(0,1); lcd.print(count); delay(500); } void setup() { lcd.begin(16, 2); pinMode(in, INPUT); pinMode(out, INPUT); pinMode(relay, OUTPUT); pinMode(led,OUTPUT); pinMode(12,INPUT); lcd.clear(); lcd.print(" ARDUINIO "); lcd.setCursor(0,1); lcd.print(" PROJECT "); delay(2000); lcd.clear(); lcd.print(" Automatic Room"); lcd.setCursor(0,1); lcd.print(" Light & "); delay(2000); lcd.clear(); lcd.print(" Bi-Direction "); lcd.setCursor(0,1); lcd.print(" Counter "); delay(2000); 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("No One in Room"); lcd.setCursor(0,1); lcd.print("Light's Off"); delay(200); } else { digitalWrite(relay, HIGH); } if (map(analogRead(A0), 0, 1023, 0, 255) >30) { digitalWrite(led, LOW); } else { digitalWrite(led, HIGH); } }
Arduino hex file can be downloaded here: arduino code.rar