RPi GPIO Python Quickstart Guideaa
RPi GPIO Python Quickstart Guideaa
uk
Pin numbering:
There are two numbering systems for GPIO pins.
Physical numbering is the easiest to understand: it tells you where to find the pin on the physical RPi board
(see below)
BCM numbers are only for I/O pins. They don’t match the physical numbers but come from the way that
they are connected to the processor on the RPi.
When writing your code you can choose to use either physical numbering or BCM numbering
Pin 2 Pin 40
Pin 1
Warning:
You might permanently break your RPi if you’re not careful when connecting anything to the GPIO pins.
Short circuits (connecting +3v or +5 either from a power pin or an output pin directly to ground) will
damage your RPi
Whilst your GPIO pins have power pins, there’s a limit to how much power they can provide. You may need
an external power supply if you’re controlling a circuit that needs anything more than a few LEDs &
switches.
Never connect a motor or speaker directly to a GPIO pin. The electrical feedback can cause damage.
Controlling the GPIO in python
You can simulate and test these commands without a RPi on create.withcode.uk
Change GPIO.BOARD to GPIO.BCM if you want BCM pin numbering instead of physical pin numbering
Change GPIO.OUT to GPIO.IN if you want to set a pin back to being an input
You can run this code online with a simulated Raspberry Pi here;
https://create.withcode.uk/python/A3