Bird
0
0

Identify the issue in this code snippet:

medium📝 Debug Q7 of 15
Raspberry Pi - GPIO Basics with Python
Identify the issue in this code snippet:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(17, GPIO.OUT)
AMissing GPIO.cleanup() call before setup
BGPIO.setmode(GPIO.BOARD) should be GPIO.setmode(GPIO.BCM)
CGPIO.setup requires a pin number as a string, not integer
DPin 17 is invalid in BOARD mode because 17 is a BCM pin number
Step-by-Step Solution
Solution:
  1. Step 1: Understand BOARD mode numbering

    In BOARD mode, pin numbers correspond to physical pins on the header.
  2. Step 2: Check pin 17

    Physical pin 17 exists, but GPIO 17 is a BCM pin number, not a physical pin number.
  3. Step 3: Conclusion

    Using 17 in BOARD mode is incorrect because 17 is a BCM pin number, not a physical pin number.
  4. Final Answer:

    Pin 17 is invalid in BOARD mode because 17 is a BCM pin number -> Option D
  5. Quick Check:

    BOARD mode expects physical pin numbers, not BCM numbers [OK]
Quick Trick: BOARD mode uses physical pins, not BCM numbers [OK]
Common Mistakes:
  • Mixing BCM pin numbers with BOARD mode
  • Assuming pin numbers are interchangeable between modes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes