From the course: Raspberry Pi Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Respond to a button press

Respond to a button press

- Now that you've seen how to turn on an LED, let's have your GPIO header read the state of an external component. We'll use a little push button. I've got a tiny one here. Clicky. Now, as with the jumper wire resistors, you can find these from any electronic suppliers, or places like Amazon where you buy most of your stuff. So power down your Raspberry Pi, and insert the push button into your breadboard. You want one leg connected to E20, which is here. And the other to F20. There we go. So pay attention to the orientation of your push button and make sure that yours is connected like this one. Next, use a short black wire to attach J20 to the ground rail. Next, use a male to female jumper wire of any color except black and red to connect pin three up here, which is GPIO 2, to A20 on the breadboard. Boot up your Raspberry Pi, open a terminal and run this command, "pinctrl set 2 ip pu." So that command causes the Raspberry Pi to configure GPIO 2 as an input IP, and it also connects it…

Contents