Bird
0
0

Which Python code snippet correctly sets up GPIO pin 17 as an input for a button on Raspberry Pi?

easy📝 Syntax Q12 of 15
Raspberry Pi - LED and Button Projects
Which Python code snippet correctly sets up GPIO pin 17 as an input for a button on Raspberry Pi?
AGPIO.setup(17, GPIO.OUT)
BGPIO.setup(17, GPIO.IN)
CGPIO.input(17, GPIO.IN)
DGPIO.output(17, GPIO.IN)
Step-by-Step Solution
Solution:
  1. Step 1: Recall GPIO setup syntax

    To set a pin as input, use GPIO.setup(pin_number, GPIO.IN).
  2. Step 2: Match the correct option

    GPIO.setup(17, GPIO.IN) uses GPIO.setup(17, GPIO.IN), which is correct for input pin setup.
  3. Final Answer:

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

    GPIO.setup(pin, GPIO.IN) sets input pin [OK]
Quick Trick: Use GPIO.setup with GPIO.IN for input pins [OK]
Common Mistakes:
  • Using GPIO.OUT instead of GPIO.IN for input
  • Confusing GPIO.input() with GPIO.setup()
  • Trying to use GPIO.output() on input pins

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes