Bird
0
0

You have a sensor connected to GPIO23 on the Raspberry Pi. Which code correctly sets up this pin using BCM numbering and reads its input?

hard📝 Application Q9 of 15
Raspberry Pi - GPIO Basics with Python
You have a sensor connected to GPIO23 on the Raspberry Pi. Which code correctly sets up this pin using BCM numbering and reads its input?
AGPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) value = GPIO.input(23)
BGPIO.setmode(GPIO.BOARD) GPIO.setup(23, GPIO.IN) value = GPIO.input(23)
CGPIO.setmode(GPIO.BCM) GPIO.setup(16, GPIO.IN) value = GPIO.input(16)
DGPIO.setmode(GPIO.BOARD) GPIO.setup(16, GPIO.IN) value = GPIO.input(16)
Step-by-Step Solution
Solution:
  1. Step 1: Use BCM mode for GPIO23

    GPIO23 is a BCM pin number, so setmode must be BCM.
  2. Step 2: Setup pin 23 as input and read value

    GPIO.setup(23, GPIO.IN) sets pin as input; GPIO.input(23) reads it.
  3. Final Answer:

    GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) value = GPIO.input(23) -> Option A
  4. Quick Check:

    BCM mode with GPIO23 pin setup and input read [OK]
Quick Trick: Match pin number with mode: BCM uses GPIO numbers [OK]
Common Mistakes:
  • Using BOARD mode with BCM pin number
  • Confusing pin 23 with physical pin 23

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes