Hi I really need help how to create code for this type of project I want to change the IR module with 2PCS of E18-D80NK
I wanted to DISPLAY on screen HOW MANY PERSON is in the room and DECREASE the number if the person goes out.
I have this code I dont know what is wrong.
#include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
int ir_right_pin = 6;
int ir_left_pin = 7;
int ir_right_state = 0;
int ir_left_state = 0;
int ir_right_state_last = -1;
int ir_left_state_last = -1;
int in_counter = 0;
int out_counter = 0;
bool bWalkIn = false;
bool bWalkOut = false;
unsigned long tm;
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);
}




