Raspberry Pi GPIO Pins
The Raspberry Pi™ hardware shares digital pins between the GPIO, Serial, SPI, and I2C interfaces. Enabling or disabling the SPI and I2C interfaces changes the availability of specific pins for use as GPIO pins.
For example, with Raspberry Pi, Model B, Rev 2:
The SPI interface is disabled by default. Enabling the SPI interface uses pins 7, 8, 9, 10, and 11.
The I2C interface is enabled by default. Disabling the I2C interface frees pins 2, 3, 28, and 29.
With both interfaces disabled, the available digital pins are: 2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27, 28, 29, 30, 31.
You can configure a GPIO pin as an input or output. If a pin is unconfigured, reading from the pin configures it as an input, and writing to the pin configures it as an output.
When you write
1 to a GPIO pin, the pin outputs +3.3V. When you write
0 to the pin, or do nothing, the pin is grounded, and outputs 0V.
When you read the GPIO pin, Raspberry Pi hardware detects the voltage of the pin. If the input voltage has approximately
the same voltage as ground, around 0V, the logical value of the pin is
If the input voltage is higher, approximately +3.3V, the logical value of the pin is
To change a pin that has already been configured, you must use
configurePin. The Raspberry Pi hardware requires this extra step to help prevent accidental damage to the board
and other components. Otherwise, for example, you could burn out an input pin that is
connected to ground by writing to it.