import machine as gpio
import utime as TM
# Define the GPIO pin for the IR sensor
Sensor_In = gpio.Pin(14, gpio.Pin.IN)
# Function to read and print the IR sensor's digital output
def read_Pir_sensor():
sensor_output = Sensor_In.value()
if sensor_output == 1:
print("PIR sensor detected an object.")
else:
print("PIR sensor did not detect an object.")
# Main loop
while True:
read_Pir_sensor()
TM.sleep(4) # Add a delay between readings