Raspberry Pi - gpiozero Library
Identify the error in this PIR sensor code snippet and choose the fix:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIR_PIN = 18
GPIO.setup(PIR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(PIR_PIN):
print("Motion!")
time.sleep(1)
except KeyboardInterrupt:
print("Exit")
