download code and circuit....
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(6,5,4,3,2,1);
#define inSensor 7
#define outSensor 8
int inStatus;
int outStatus;
int countin = 0;
int countout = 0;
int in;
int out;
int now;
#define relay 9
void setup() {
lcd.begin(16,2);
pinMode(inSensor, INPUT);
pinMode(outSensor, INPUT);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
lcd.setCursor(0,0); // put your setup code here, to run once:
lcd.print("Visitor counter");
delay(1000);
}
void loop() {
inStatus = digitalRead(inSensor);
outStatus = digitalRead(outSensor);
if (inStatus == 1)
{
in = countin++;
}
if (outStatus == 1)
{
out = countout++;
}
now = in - out;
if (now <= 0)
{
digitalWrite(relay, LOW);
lcd.clear();
lcd.setCursor(0,0); // put your setup code here, to run once:
lcd.print("No Visitor");
lcd.setCursor(0,1);
lcd.print("Light Off");
delay(500);
}
else
{
digitalWrite(relay, HIGH);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Current Visitor");
lcd.print(now);
lcd.setCursor(0,1);
lcd.print("IN: ");
lcd.print(in);
lcd.setCursor(8,1);
lcd.print("OUT: ");
lcd.print(out);
delay(500);
}
}
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें