# script to interface ir sensor with esp32 using led and buzzer
from machine import Pin
import time
ir_sensor_pin = Pin(27, Pin.IN)
led_pin = Pin(13, Pin.OUT)
buzzer_pin = Pin(12, Pin.OUT)
while True:
if ir_sensor_pin.value() == 1:
print("IR sensor detected an object!")
led_pin.on()
buzzer_pin.on()
time.sleep(1)
else:
print("No object detected.")
led_pin.off()
buzzer_pin.off()
time.sleep(0.5)