Complete the code to import the GPIO library for Raspberry Pi.
import [1]
The RPi.GPIO library is used to control GPIO pins on Raspberry Pi.
Complete the code to set the GPIO mode to BCM numbering.
GPIO.setmode([1])Setting GPIO mode to GPIO.BCM uses the Broadcom chip pin numbers.
Fix the error in setting up GPIO pin 17 as input with pull-down resistor.
GPIO.setup(17, [1], pull_up_down=GPIO.PUD_DOWN)
GPIO pin 17 must be set as input (GPIO.IN) to read the PIR sensor signal.
Fill both blanks to read the PIR sensor state and print 'Motion detected!' when motion is detected.
if GPIO.[1](17) == [2]: print('Motion detected!')
Use GPIO.input(17) to read the sensor state and compare it to GPIO.HIGH which means motion detected.
Fill all three blanks to set up GPIO, read PIR sensor, and clean up GPIO after use.
import RPi.GPIO as GPIO import [1] GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) try: while True: if GPIO.input(17) == GPIO.HIGH: print('[2]') [3](0.5) except KeyboardInterrupt: GPIO.cleanup()
The time module is imported to use time.sleep() for delays. The message 'Motion detected!' is printed when motion is detected.