0
0
Raspberry Piprogramming~10 mins

GPIO pin numbering (BCM vs BOARD) in Raspberry Pi - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Concept Flow - GPIO pin numbering (BCM vs BOARD)
Start: Choose Pin Numbering Mode
BOARD Mode Selected?
YesUse Physical Pin Numbers
Access Pins by Position
Perform GPIO Actions
BCM Mode Selected?
YesUse Broadcom GPIO Numbers
Access Pins by GPIO Number
Perform GPIO Actions
Choose between BOARD (physical pin positions) or BCM (Broadcom chip numbers) to access Raspberry Pi GPIO pins before performing actions.
Execution Sample
Raspberry Pi
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.output(7, GPIO.HIGH)
This code sets the pin numbering to BOARD mode, sets physical pin 7 as output, and turns it on.
Execution Table
StepActionPin Numbering ModePin ReferencedEffect
1Import GPIO libraryNoneNoneGPIO module ready
2Set mode to BOARDBOARDNonePins referenced by physical position
3Setup pin 7 as outputBOARDPhysical pin 7Pin 7 ready for output
4Set pin 7 HIGHBOARDPhysical pin 7Pin 7 output set to HIGH (on)
5EndBOARDPhysical pin 7Program finished
💡 Program ends after setting pin 7 HIGH in BOARD mode
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Pin Numbering ModeNoneBOARDBOARDBOARDBOARD
Pin 7 StateUndefinedUndefinedConfigured as OutputHIGHHIGH
Key Moments - 2 Insights
Why does setting GPIO.setmode(GPIO.BOARD) change how pins are referenced?
Because BOARD mode uses the physical pin numbers on the Raspberry Pi header, not the Broadcom chip numbers. See execution_table step 2 where mode changes to BOARD.
What happens if you use BCM numbering but reference a physical pin number?
The wrong pin will be accessed or an error may occur because BCM mode expects GPIO numbers, not physical positions. This is shown by contrasting step 2 and 3 in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the pin numbering mode after step 3?
ANone
BBCM
CBOARD
DUndefined
💡 Hint
Check the 'Pin Numbering Mode' column at step 3 in the execution_table.
At which step is pin 7 configured as an output?
AStep 3
BStep 4
CStep 2
DStep 1
💡 Hint
Look at the 'Effect' column in execution_table for when pin 7 is set as output.
If you change GPIO.setmode(GPIO.BCM) in the code, what changes in the execution_table?
APin numbering mode stays BOARD but pin referenced changes
BPin numbering mode changes to BCM and pin referenced changes to GPIO number
CNo change in pin numbering mode or pin referenced
DProgram will not run
💡 Hint
Refer to the concept_flow and execution_table showing mode selection effect on pin referencing.
Concept Snapshot
GPIO Pin Numbering Modes:
- BOARD: Use physical pin numbers on header
- BCM: Use Broadcom GPIO chip numbers
Set mode with GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Pin references depend on chosen mode
Always set mode before accessing pins
Full Transcript
This visual execution shows how Raspberry Pi GPIO pin numbering works. First, you choose a mode: BOARD or BCM. BOARD mode uses the physical pin positions on the Pi's header, while BCM mode uses the Broadcom chip's GPIO numbers. The example code sets BOARD mode, then sets physical pin 7 as output and turns it on. The execution table traces each step, showing the mode and pin referenced. Variable tracking shows how the mode and pin state change. Key moments clarify why mode matters and what happens if you mix numbering systems. The quiz tests understanding of mode and pin setup. Remember to always set the pin numbering mode before controlling pins to avoid mistakes.