Bird
Raised Fist0
Raspberry Piprogramming~20 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. Which GPIO pin numbering mode uses the physical pin numbers on the Raspberry Pi header?
easy
A. BOARD numbering mode
B. BCM numbering mode
C. WIRING numbering mode
D. PIN numbering mode

Solution

  1. Step 1: Understand GPIO numbering modes

    GPIO pins can be numbered by their physical location (BOARD) or by the Broadcom chip numbering (BCM).
  2. Step 2: Identify physical pin numbering

    BOARD mode refers to the physical pin numbers on the Raspberry Pi header.
  3. Final Answer:

    BOARD numbering mode -> Option A
  4. Quick Check:

    Physical pins = BOARD [OK]
Hint: BOARD mode matches physical pin numbers on the header [OK]
Common Mistakes:
  • Confusing BCM with physical pin numbers
  • Thinking BCM is the physical numbering
  • Assuming WIRING or PIN modes exist
2. Which of the following is the correct way to set GPIO pin numbering to BCM mode in Python?
easy
A. GPIO.setmode(GPIO.BOARD)
B. GPIO.setupmode(GPIO.BCM)
C. GPIO.mode(GPIO.BCM)
D. GPIO.setmode(GPIO.BCM)

Solution

  1. Step 1: Recall the correct function to set GPIO mode

    The function to set numbering mode is GPIO.setmode().
  2. Step 2: Use the correct constant for BCM mode

    GPIO.BCM is the constant for BCM numbering mode.
  3. Final Answer:

    GPIO.setmode(GPIO.BCM) -> Option D
  4. Quick Check:

    Use setmode with BCM constant [OK]
Hint: Use GPIO.setmode(GPIO.BCM) to select BCM numbering [OK]
Common Mistakes:
  • Using GPIO.mode instead of GPIO.setmode
  • Using BOARD instead of BCM constant
  • Calling GPIO.setupmode which doesn't exist
3. Given the code snippet:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.output(7, GPIO.HIGH)

Which physical pin is set HIGH?
medium
A. Pin 11 on the physical header
B. GPIO pin number 7 on the Broadcom chip
C. Pin 7 on the physical header
D. GPIO pin number 11 on the Broadcom chip

Solution

  1. Step 1: Identify the numbering mode used

    The code uses GPIO.setmode(GPIO.BOARD), so pin numbers refer to physical header pins.
  2. Step 2: Check which pin is set HIGH

    GPIO.setup(7, GPIO.OUT) and GPIO.output(7, GPIO.HIGH) set physical pin 7 HIGH.
  3. Final Answer:

    Pin 7 on the physical header -> Option C
  4. Quick Check:

    BOARD mode pin 7 = physical pin 7 [OK]
Hint: BOARD mode means pin number is physical header pin [OK]
Common Mistakes:
  • Confusing BOARD pin 7 with BCM GPIO 7
  • Assuming pin 7 means BCM numbering
  • Mixing physical pin numbers with BCM numbers
4. 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.
medium
A. Pin 10 in BCM does not match physical pin 10 wiring
B. GPIO.setmode(GPIO.BOARD) should be used instead
C. GPIO.output() requires pin number as string
D. GPIO.setup() cannot use BCM numbering

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]
Hint: 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
5. You want to control an LED connected to physical pin 12 on the Raspberry Pi header. Which code snippet correctly sets the pin HIGH using BCM numbering?
hard
A. GPIO.setmode(GPIO.BOARD) GPIO.setup(12, GPIO.OUT) GPIO.output(12, GPIO.HIGH)
B. GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.output(18, GPIO.HIGH)
C. GPIO.setmode(GPIO.BCM) GPIO.setup(12, GPIO.OUT) GPIO.output(12, GPIO.HIGH)
D. GPIO.setmode(GPIO.BOARD) GPIO.setup(18, GPIO.OUT) GPIO.output(18, GPIO.HIGH)

Solution

  1. Step 1: Identify physical pin 12's BCM number

    Physical pin 12 corresponds to BCM GPIO 18 on Raspberry Pi.
  2. Step 2: Use BCM numbering mode and correct pin

    Set mode to GPIO.BCM and use pin 18 in setup and output.
  3. Final Answer:

    GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) GPIO.output(18, GPIO.HIGH) -> Option B
  4. Quick Check:

    Physical pin 12 = BCM 18, use BCM mode [OK]
Hint: Convert physical pin to BCM before coding [OK]
Common Mistakes:
  • Using physical pin number with BCM mode
  • Using BCM pin number with BOARD mode
  • Mixing pin numbers without conversion
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard