Bird
0
0

Which of the following is the correct way to set up a GPIO pin as input for a PIR sensor in Python using RPi.GPIO?

easy📝 Syntax Q12 of 15
Raspberry Pi - gpiozero Library

Which of the following is the correct way to set up a GPIO pin as input for a PIR sensor in Python using RPi.GPIO?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
# What goes here?
AGPIO.setup(17, GPIO.IN)
BGPIO.setup(17, GPIO.OUT)
CGPIO.input(17)
DGPIO.output(17, GPIO.HIGH)
Step-by-Step Solution
Solution:
  1. Step 1: Identify pin mode for PIR sensor input

    PIR sensor output should be read as input on the Raspberry Pi GPIO pin.
  2. Step 2: Match correct GPIO setup syntax

    GPIO.setup(pin_number, GPIO.IN) sets the pin as input, which is needed to read sensor data.
  3. Final Answer:

    GPIO.setup(17, GPIO.IN) -> Option A
  4. Quick Check:

    GPIO input setup = GPIO.setup(pin, GPIO.IN) [OK]
Quick Trick: Use GPIO.IN to read sensor signals, not GPIO.OUT [OK]
Common Mistakes:
  • Using GPIO.OUT instead of GPIO.IN
  • Calling GPIO.input() instead of GPIO.setup() to configure pin
  • Trying to write output to sensor pin

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes