4. Setup wiring: ATX-buttons, LEDs and Piezo-buzzer on Raspberry

Following notes are only for the Raspberry Pi 3B/3B+/4B NOT for other models!

GPIO pins

The Raspberry Pi has two pin headers that are physically labeled (column Physical in following table). WiringPi software does number the pins differently (http://wiringpi.com/, column wPi). The right column with the physical pins 2, 4, 6, .., 40 is lying on the outside of the Raspberry Pi. Pin 40 is located nearby the USB jacks. The left column with the odd numbered pins is lying inside of the Raspberry Pi board. You can get an overview of all pins with

gpio readall

produces

+-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | OUT | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 1 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 1 | OUT | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | OUT | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 1 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+

Connection of CPU fan

The connection may differ depending on the model. Therefore observe the manufacturer's information!

Connection of Piezo-buzzer

The buzzer is connected to the physical pins 12 (+) and 14 (ground / GND).
Test with

gpio mode 1 pwm # physical pin 12 corresponds to pin 1 in wiringPi
gpio pwmTone 1 2000 # sound on
gpio pwmTone 1 0 # sound off

Connection of ATX buttons and LEDs

The ATX button for shutdown is connected to the physical pins 39 and 40.
Test with

sudo systemctl stop gpio-input # 1st, deactivate the service
gpio mode 29 up # physical pin 40 corresponds to pin 29 in wiringPi
gpio read 29 # should deliver 1 if the button is not pressed
# should deliver 0 when the button is pressed

The green LED is connected to physical pin 36 (wiringPi: 27), the ground to pin 34.
The red LED is connected to physical pin 32 (wiringPi: 26), the ground to pin 30.
Test with

gpio mode 27 output # wiringPi: 27 for green, 26 for red
gpio write 27 on # corresponding LED (here: green) enlightens
gpio write 27 off # corresponding LED gets dark

ATTENTION: the pin assignment of LEDs and buttons has been changed a few times - since the first scanner setup. Changes were necessary, e.g. depending on ATX cable pair and for special Raspberry Pi housings, e.g. the NesPi.

Reactivate the service after testing the buttons

sudo systemctl start gpio-input