from machine import Pin
from time import sleep
res= Pin(34,Pin.IN)
led= Pin(2,Pin.OUT)
buzzer= Pin(21,Pin.OUT)
while True:
if(res.value()==1):
led.on()
buzzer.on()
print("object detected ")
else:
led.off()
buzzer.off()
print("There is no detected")
sleep(0.5)