systemypomiarowe.pl

Close-up of the assembled P161002 board with Microchip devices in SMD packages Board visualisation with an STM32 microcontroller, SD card socket and GPS module Three-dimensional visualisation of a board with a relay, buzzer and connectors Part of a schematic with an INA326 instrumentation amplifier and MCP3304 A/D converter Three-dimensional visualisation of a densely populated communication module board Device front panel with labelled buttons, volume knobs and a speaker Technical drawing of the front panel showing the layout of buttons and knobs Assembled board with a PIC18F2550 microcontroller, USB socket and trimmer potentiometers TouchGFX interface source code for STM32 in the Visual Studio Code editor Printed circuit board layout with copper layers and component placement
Main page Offer

Raspberry Pi - GPIO port

Configuring and using the GPIO port

To test working with the GPIO port I used the KAmodLED8 test board. The board carries a 74LVC541 octal buffer and eight LEDs. This arrangement does not load the ports of the processor on the Raspberry Pi board, which would happen if the LEDs were connected directly.

The signals on the P1 header of the Raspberry Pi are laid out as shown in the figure.

Signal layout on the Raspberry Pi P1 header - revision 2

Fig. Signal layout on the P1 header of version 2.

Signal layout on the Raspberry Pi P1 header - revision 4

Fig. Signal layout on the P1 header of version 4.

How the KAmodLED8 module is connected.

KAmodLED8 module with eight LEDs

Fig. The KAmodLED8 module.

The module was connected to the P1 header according to the diagram below.

Wiring diagram of the KAmodLED8 module to the Raspberry Pi P1 header

Fig. Wiring diagram of the KAmodLED8 module and the Raspberry Pi.

Wires with specially prepared ends were used for the connection. The connected module is shown in the figure below.

KAmodLED8 module connected to a Raspberry Pi with wires

Fig. The connected KAmodLED8 module.

The connections were made so as to leave the SPI, I2C and UART interfaces free for other uses. On the header drawing these are the signals marked in blue.

To use the GPIO port we need the wiringPi package, which lets us set the direction and the states of individual GPIO outputs from the command line. So we have to download and compile it. It can be obtained from https://projects.drogon.net/raspberry-pi/wiringpi/ and then unpacked in the home directory.

tar xfz wiringPi.tgz

We should also install the library supporting the I2C standard, because compiling wiringPi may otherwise fail. To do that we issue the command:

sudo apt-get install libi2c-dev

To compile the library we run the following commands in turn:

cd wiringPi/wiringPi
make
sudo make install
cd ../gpio
make

To drive a GPIO output line we issue the command:

sudo ./gpio -g mode 4 out

where 4 is the GPIO line number and "out" means that we configure the line as an output. To set state 1 on the configured GPIO line we type:

sudo ./gpio -g write 4 1

where 4 is the GPIO port number and 1 is the logic state on that output. Sometimes a GPIO line has to be read. Once it is configured as an input, using the "in" parameter, we read it from the command line with:

sudo ./gpio -g read 4


The GPIO port is enough for simple experiments, but with more signals a dedicated expansion board is needed - such as the frontpanel for the Raspberry Pi we describe. We design and build such modules to order.



Copyright ©2026 systemypomiarowe.pl.