Raspberry Pi Button
A great starter hardware project using the raspberry pi is hooking up a simple tactile switch to the raspberry gpio and detecting button presses in python.
Raspberry pi button. The working of raspberry pi push button interface is very easy to understand. Interfacing push button with raspberry pi is very simple. Out of the two ways to set up the button the gpio zero method seems to be the easiest. In this project i will show you how to interface 4 pin push button switch with raspberry pi 2 and also connect one led so that when button is pressed led will turn on and on button release it will turns off.
However programmer sam pearce informed me that you can actually shut down power up the pi with a simple button press taking care of 90 percent of my problem with rather minimal effort. This guide will guide you through setting up the circuit with the raspberry pi and reading the state of the button in python. It is still worth learning about the rpi gpio library as most beginner raspberry pi projects use it. In fact to power up all that s required is to connect physical pin 5 bcm 3 to the ground next to it.
Now it waits for a change in state of the input pin which happens only when the button is pressed. When the python script is run the raspberry pi initializes the button pin as input with internal pull up and led pin as output.