from machine import Pin, I2C
import ssd1306
import time
i2c = I2C(0, scl=Pin(5), sda=Pin(4))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
sensor_pir = Pin(15, Pin.IN)
def mostrar_estado(detectado):
oled.fill(0)
if detectado:
oled.text("NIGGA!!!!", 25, 25)
else:
oled.text("NO NIGGA", 0, 0)
oled.text("DETECTED", 0, 12)
oled.show()
ultimo_estado = -1
while True:
estado_actual = sensor_pir.value()
if estado_actual != ultimo_estado:
if estado_actual == 1:
mostrar_estado(True)
else:
mostrar_estado(False)
ultimo_estado = estado_actual
time.sleep(0.05)