Today we will build a small circuit that lets you execute commands in Raspberry Pi to do whatever we want when a button is pressed (in our case to start the shutdown process). This circuit is quite simple and requires only one resistor and one button. Some LEDs have been added for Raspberry PI to be able to give feedback without having to have a display connected or be connected remotely.

Schematic

Bill of materials (BOM)

Circuit:

1x 10K Ohms Resistor (R1)

1x SPST Button (SW1)

1x 1K Ohms Resistor (R4)

1x 220 Ohms Resistor (R3)

1x 680 Ohms Resistor (R2)

1x 3mm Red LED

1x 3mm Blue LED

1x 3mm Yellow LED

IC/Components Pin-out

The Pinout of Raspberry PI Model B Rev. 2 is as follows:

The Raspberry PI 2 Model B Pinout is as follows:

Code

So that the circuit works we will need to execute the “program” that will give the shutdown instruction when it detects that the button was pressed.

The system used to run the displayed code was the raspbian jessie of 2015-09-24 and a Raspberry PI 2 was used. It can be downloaded from here.

If you want to use a script to test only if the button and the LEDs are working:

Social

Your browser does not support JavaScript!Your browser does not support JavaScript!Your browser does not support JavaScript!Your browser does not support JavaScript!Your browser does not support JavaScript!