from machine import Pin, PWM
import time
from random import randint
LedRojo = PWM(Pin(0))
LedVerde = PWM(Pin(1))
LedAzul = PWM(Pin(2))
Buzzer = PWM(Pin(3))
Buzzer.duty_u16(0)
Buzzer.freq(500)
PIR = Pin(28, Pin.IN)
def Alarma():
for i in range(5):
Buzzer.duty_u16(1000)
LedRojo.duty_u16(randint(0,65535))
LedVerde.duty_u16(randint(0,65535))
LedAzul.duty_u16(randint(0,65535))
time.sleep(0.2)
Buzzer.duty_u16(0)
LedRojo.duty_u16(0)
LedVerde.duty_u16(0)
LedAzul.duty_u16(0)
time.sleep(0.2)
while True:
Buzzer.duty_u16(0)
LedRojo.duty_u16(0)
LedVerde.duty_u16(0)
LedAzul.duty_u16(0)
if PIR.value()==1:
Alarma()
time.sleep(3)
time.sleep(0.1)