from machine import Pin #Importa a classe Pin da biblioteca machine
from time import sleep_ms #Importa a função sleep_ms da biblioteca time
LED = Pin(16, Pin.OUT) #Define a variável LED ao pino GPIO17, como saída
sensor = Pin(17, Pin.IN)
while True:
leitura = sensor.value()
if leitura == 1:
LED.value(1)
print("Objeto detectado!!")
else:
LED.value(0)
sleep_ms(500)