from machine import Pin
from gpio_lcd import GpioLcd
import time
b=Pin(4, Pin.IN)
a=Pin(6, Pin.IN)
count=0
p=1
q=1
lcd = GpioLcd(rs_pin= Pin(15), enable_pin= Pin(14), d4_pin= Pin(13), d5_pin= Pin(12), d6_pin= Pin(11), d7_pin= Pin(10))
lcd.move_to(0,0)
lcd.putstr("PERSON COUNTER")
lcd.move_to(0,1)
lcd.putstr("TOTAL COUNT:")
while (1):
c=b.value()
d=a.value()
if c==0:
count+=1
while(1):
time.sleep(0.2)
if b.value()==1:
break
if d==0:
count-=1
while(1):
time.sleep(0.2)
if a.value()==1:
break
if count<0:
count =0
elif count>99:
count=99
else:
count=count
lcd.move_to(13,1)
lcd.putstr(str(count))
time.sleep(0.2)