0
0
Raspberry Piprogramming~20 mins

GPIO pin numbering (BCM vs BOARD) in Raspberry Pi - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GPIO Pin Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Understanding BCM vs BOARD numbering output

What will be the output of this Python code snippet using the RPi.GPIO library?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
print(GPIO.getmode())

Assume the code runs without errors.

Raspberry Pi
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
print(GPIO.getmode())
AGPIO.BOARD
B10
CGPIO.BCM
D11
Attempts:
2 left
💡 Hint

Check the RPi.GPIO documentation for mode constants.

🧠 Conceptual
intermediate
1:30remaining
Difference between BCM and BOARD numbering

Which statement correctly describes the difference between BCM and BOARD pin numbering on a Raspberry Pi?

ABoth BCM and BOARD numbering refer to the same pin numbers but in different order.
BBOARD numbering refers to the physical pin numbers on the header, BCM refers to Broadcom chip pin numbers.
CBCM numbering refers to the physical pin numbers on the header, BOARD refers to Broadcom chip pin numbers.
DBCM numbering is deprecated and replaced by BOARD numbering.
Attempts:
2 left
💡 Hint

Think about what 'BOARD' and 'BCM' stand for.

🔧 Debug
advanced
2:00remaining
Pin numbering mode mismatch error

What error will this code produce?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.HIGH)
ANo error, pin 17 is set high
BRuntimeError: The channel has not been set up as an output
CRuntimeError: GPIO pin numbering mode mismatch
DValueError: Invalid GPIO pin number
Attempts:
2 left
💡 Hint

Check if pin 17 is valid in BOARD mode.

Predict Output
advanced
2:00remaining
Output of pin number mapping

What will this code print?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
print(GPIO.gpio_function(18))
A1
B2
C0
D3
Attempts:
2 left
💡 Hint

Check what gpio_function returns for an unconfigured pin.

🧠 Conceptual
expert
2:30remaining
Choosing pin numbering mode for cross-platform code

You want to write a Python script using RPi.GPIO that works on different Raspberry Pi models without changing pin numbers. Which pin numbering mode should you use?

AUse BOARD mode because physical pins are consistent across models.
BUse BCM mode because GPIO numbers are consistent across models.
CUse BOARD mode because GPIO numbers are consistent across models.
DUse BCM mode because physical pins are consistent across models.
Attempts:
2 left
💡 Hint

Think about physical pin layout consistency.