There are two kinds of Input and Output pin numbering for the Raspberry pi. One is the BCM and the other is BOARD. Basically these pin numberings are useful for writing python script for the Raspberry Pi.
GPIO BOARD– This type of pin numbering refers to the number of the pin in the plug, i.e, the numbers printed on the board, for example, P1. The advantage of this type of numbering is, it will not change even though the version of board changes.
GPIO BCM– The BCM option refers to the pin by “Broadcom SOC Channel. They signify the Broadcom SOC channel designation. The BCM channel changes as the version number changes.
Note: It is very important to wire the GPIO pins with limited resistors to avoid serious damage to the Raspberry Pi. LEDs must have resistors to limit the current passing through them. The motors should not be connected to the GPIO pins directly.
Identification of the pin numberings via Linux command
There is a Linux command to find out which name is for which GPIO pin. So in that case, we do not have to worry about a tutorial or a cheat sheet to have by our side to check out the pin numberings of the Raspberry Pi all the time.
Type the following command in the terminal,
pinout
Which is better? BCM or BOARD
the BCM numbers changed between versions of the Pi1 Model B, and you’ll need to work out which one you have guide here. So it may be safer to use the BOARD numbers if you are going to use more than one Raspberry Pi in a project.
- The Model B+ uses the same numbering as the Model B r2.0, and adds new pins (board numbers 27-40).
- The Raspberry Pi Zero, Pi 2B and Pi 3B use the same numbering as the B+.
How to use the GPIO pin numbers in Python?
I have used a simple LED blink python program with Raspberry Pi. Here the GPIO.BOARD is the type of pin numbering which was explained earlier. The number 11 is the pin for LED and considered as an output.
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode (GPIO.BOARD)
GPIO.setup (11,GPIO.OUT)
while True:
GPIO.output(11,True)
time.sleep(2)
GPIO.output(11,False)
time.sleep(2)
Click here for an LED blinking tutorial with Raspberry Pi.