Newer
Older
PiPins / gpio.txt
root on 18 Mar 2020 2 KB pin 1 marking
	 1](2	
BCM 2	 3)(4	
BCM 3	 5)(6	
	 7)(8	BCM 14
	 9)(10	BCM 15
BCM 17	11)(12	BCM 18
BCM 27	13)(14	
BCM 22	15)(16	BCM 23
	17)(18	BCM 24
BCM 10	19)(20	
BCM 9	21)(22	BCM 25
BCM 11	23)(24	BCM 8
	25)(26	BCM 7
BCM 0	27)(28	BCM 1
BCM 5	29)(30	
BCM 6	31)(32	BCM 12
BCM 13	33)(34	
BCM 19	35)(36	BCM 16
BCM 26	37)(38	BCM 20
	39)(40	BCM 21

BCM - Broadcom pin number, commonly called "GPIO", these are the ones you probably want to use with RPi.GPIO and GPIO Zero

- Outputs and Inputs -

Other GPIO pins are capable of a 3.3V output, also referred to as setting the pin HIGH in code. When an output pin is LOW this means that it is simply providing 0V.

A GPIO pin designated as an input pin can be read as HIGH (3.3V) or LOW (0V). This is made easier with the use of internal pull-up or pull-down resistors. Pins GPIO 2 and GPIO 3 have fixed pull-up resistors, but for other pins this can be configured in software. Do not provide the pins with greater than 3.3V: this is a quick way to damage your Raspberry Pi!

- PWM -

PWM (Pulse Width Modulation) is used with components such as motors, servos and LEDs by sending short pulses to control how much power they recieve.

PWM is also possible on the Raspberry Pi. GPIO 12, GPIO 13, GPIO 18, GPIO 19 are hardware PWM capable, though the Raspberry Pi is also able to provide software PWM through libraries such as pigpio on all pins.

- BOARD or BCM? Which one to use? -

Each pin has two numbers attached to it. Its BOARD number (the numbers in the circle) and its BCM (Broadcom SOC channel) number. You can choose which convention to use when you write your Python code:

1. GPIO/BCM numbering: GPIO.setmode(GPIO.BCM)
2. Board numbering: GPIO.setmode(GPIO.BOARD)
You can only use one convention in each DIY project, so select a one which makes most sense to you (the output is the same). It is worth noting however, that certain peripherals rely on GPIO/BCM numbering (RPi.GPIO and GPIO Zero).

The easiest way to control the GPIO pins is using the RPi.GPIO Python library.

- Pinout command -

A handy reference can be accessed on the Raspberry Pi by opening a Terminal window and running the command: "pinout". This tool is provided by the GPIO Zero Python library, which it is installed by default on the Raspbian desktop image, but not on Raspbian Lite.