from machine import Pin
from time import sleep_ms
powerA=Pin(12,Pin.OUT)
powerB=Pin(13,Pin.OUT)
sensor=Pin(34,Pin.IN)
pins=[Pin(23,Pin.OUT),Pin(22,Pin.OUT),Pin(15,Pin.OUT),Pin(2,Pin.OUT),Pin(4,Pin.OUT),
Pin(21,Pin.OUT),Pin(19,Pin.OUT)]
char=[
[0,0,0,0,0,0,1],
[1,0,0,1,1,1,1],
[0,0,1,0,0,1,0],
[0,0,0,0,1,1,0],
[1,0,0,1,1,0,0],
[0,1,0,0,1,0,0],
[0,1,0,0,0,0,0],
[0,0,0,1,1,1,1],
[0,0,0,0,0,0,0],
[0,0,0,0,1,0,0]
]
count=0
while True:
if sensor.value()==1:
count=count+1
print("one Person entered in a room")
print("Number of person in a room : ",count)
unit=count%10
ten=count//10
unit=char[unit]
ten=char[ten]
for _ in range(10):
for i in range(7):
pins[i].value(unit[i])
powerA.on()
sleep_ms(50)
powerA.off()
for i in range(7):
pins[i].value(ten[i])
powerB.on()
sleep_ms(50)
powerB.off()
if count>99:
count=0