print("Sensor!")
import machine
import time
from machine import PWM, Pin
led1 = machine.Pin(2,machine.Pin.OUT)
j = 0
temp = 0
estado = False
def sensor(Pin):
global j
global temp
if((time.ticks_ms()-temp) > 300):
temp = time.ticks_ms()
j+=1
print("Movimento detectado!")
bot = Pin(17, Pin.IN)
bot.irq(trigger=Pin.IRQ_RISING, handler=sensor)
ti = 0
while True:
if((j!=0) and ((time.ticks_ms()- ti) >= 500)):
led1.value(estado)
time.sleep_ms(100)
estado = not estado
elif(j==0):
led1.value(0)