O'Reilly logo

Banana Pi Cookbook by Ryad El-Dajani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required