Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Banana Pi Cookbook

You're reading from  Banana Pi Cookbook

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781783552443
Pages 200 pages
Edition 1st Edition
Languages
Author (1):
Ryad El-Dajani Ryad El-Dajani
Profile icon Ryad El-Dajani

Using the GPIO input with a pushbutton


We controlled the LED in the previous two recipes by the GPIO output mode. The next step is to use the GPIO pins as input pins. There is a basic electronic component to demonstrate the GPIO input mode easily—the pushbutton.

In this recipe, we are switching on an LED while a pushbutton is pressed. Once the pushbutton is released, the LED is switched off again.

Getting ready

The following ingredients are required for this recipe:

  • A Linux system on the Banana Pi

  • Access to the shell

  • A 5 mm LED (forward voltage 2.0 V)

  • A pushbutton

  • A 470 Ω resistor

  • A 10K Ω resistor

  • A breadboard

  • Four female to male jumper wires

  • One male to male jumper wire

How to do it…

We build the circuit and program the Banana Pi afterwards.

Preparing the circuit

The circuit in this recipe looks a bit more complex than the previous one.

Note

Before you connect or disconnect any electrical parts, power off your Banana Pi and also unplug the power supply.

Let's see how to prepare the circuit:

  1. Connect the jumpers...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}