Book Image

Banana Pi Cookbook

By : Ryad El-Dajani
Book Image

Banana Pi Cookbook

By: Ryad El-Dajani

Overview of this book

Table of Contents (13 chapters)

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...