Bird
0
0

Which of the following Python code snippets correctly sets GPIO pin 17 as input for a PIR sensor?

easy📝 Syntax Q3 of 15
Raspberry Pi - gpiozero Library

Which of the following Python code snippets correctly sets GPIO pin 17 as input for a PIR sensor?

AGPIO.setup(GPIO.IN, 17)
BGPIO.setup(GPIO.OUT, 17)
CGPIO.setup(17, GPIO.OUT)
DGPIO.setup(17, GPIO.IN)
Step-by-Step Solution
Solution:
  1. Step 1: Recall GPIO.setup syntax

    The correct syntax is GPIO.setup(pin_number, direction).
  2. Step 2: Match correct pin and direction

    Pin 17 should be set as input using GPIO.IN.
  3. Final Answer:

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

    GPIO setup input syntax = GPIO.setup(pin, GPIO.IN) [OK]
Quick Trick: Pin number first, then direction in GPIO.setup() [OK]
Common Mistakes:
  • Swapping pin and direction arguments
  • Using GPIO.OUT instead of GPIO.IN for input
  • Incorrect argument order causing errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes