from machine import Pin, I2C
import ssd1306
import time
pin_pir = Pin(5, Pin.IN)
buz_pin = Pin(18, Pin.OUT)
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
def mov_detecte(pin):
oled.fill(0)
oled.text("Mouvement detecte", 0, 10)
oled.show()
buz_pin.on()
time.sleep(1)
buz_pin.off()
oled.fill(0)
oled.text("Pas de mouvement", 0, 0)
oled.show()
pin_pir.irq(trigger=Pin.IRQ_RISING, handler=mov_detecte)
oled.fill(0)
oled.text("Pas de mouvement", 0, 0)
oled.show()
while True:
time.sleep(0.1)