from machine import Pin
from time import sleep
ir_senser = Pin(2,Pin.IN)
green_led = Pin(3,Pin.OUT)
reset_button = Pin(4,Pin.IN)
capacity = 0
current_count = 0
while capacity <= 0:
print("Please enter the event hall capacity: ")
capacity = int(input())
if capacity <= 0:
print("Capacity must be a positive number. Please try again")
print("Event hall capacity is set to", capacity)
print("Visiter counter is ready")
printed_full_msg = False
while True:
if current_count >= capacity:
if reset_button.value() == 1:
current_count = 0
printed_full_msg = False
print("Vistor counter reset! System is ready for new entries.")
sleep(0.3)
if current_count < capacity and ir_senser.value() == 1:
current_count += 1
print("Current Count:", current_count, "/", capacity)
green_led.on()
sleep(0.1)
green_led.off()
sleep(0.1)
printed_full_msg = False
while ir_senser.value() == 1:
sleep(0.05)
if current_count >= capacity and not printed_full_msg:
print("Event hall is FULL! Press Reset button to continue.")
printed_full_msg = True
sleep(0.1)
# GP2 - IR
# GP3 - LED6
# GP4 - PB1