Bird
0
0

What is wrong with this code snippet?

medium📝 Debug Q14 of 15
Raspberry Pi - GPIO Basics with Python
What is wrong with this code snippet?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(10, GPIO.OUT)
GPIO.output(10, GPIO.HIGH)

Assuming the LED is wired to physical pin 10 on the header.
APin 10 in BCM does not match physical pin 10 wiring
BGPIO.setmode(GPIO.BOARD) should be used instead
CGPIO.output() requires pin number as string
DGPIO.setup() cannot use BCM numbering
Step-by-Step Solution
Solution:
  1. Step 1: Understand numbering mismatch

    GPIO.setmode(GPIO.BCM) means pin numbers refer to Broadcom chip pins, not physical pins.
  2. Step 2: Check wiring vs numbering

    Physical pin 10 corresponds to BCM GPIO 15. The code uses BCM pin 10 (physical pin 19), so it does not control the wired physical pin 10.
  3. Final Answer:

    Pin 10 in BCM does not match physical pin 10 wiring -> Option A
  4. Quick Check:

    BCM 10 controls physical 19 ≠ pin 10 [OK]
Quick Trick: Match numbering mode to wiring to avoid pin mismatch [OK]
Common Mistakes:
  • Assuming physical pin numbers work with BCM mode
  • Using string instead of int for pin number
  • Thinking GPIO.setup can't use BCM numbering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes