from machine import Pin, Timer
import tm1637
from time import ticks_ms
# from tm1637 import _SEGMENTS
pir =Pin(27,Pin.OUT,Pin.PULL_UP)
led1=Pin(33,Pin.OUT)
disp =tm1637.TM1637(clk=Pin(25),dio=Pin(26))
led1.value(0)
def det_lit(sen,led):
if sen.value()==1:
led.value(1)
disp.scroll("Motiondetected", delay=250)
# disp.show("on")
else :
led.value(0)
disp.scroll("Motionended", delay=250)
# disp.show("off")
def pir_ctrl(tim):
det_lit(pir,led1)
# tim=Timer(0)
# tim.init(period=250,mode = Timer.PERIODIC,callback=pir_ctrl)
# while True:
# pass
# pir.irq(pir_ctrl,Pin.IRQ_RISING)
# time.sleep(10)
# pir.irq(pir_ctrl,Pin.IRQ_FALLING)
while True:
pass