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

Programming the LED

Switching on an LED by a command is one thing. The other is controlling the LED programmatically. In this recipe, we are going to write a real program in C and in Python to switch the LED on and off periodically.

Getting ready

We require the very same breadboard construction from the previous recipe:

  • A Linux system on the Banana Pi
  • Access to the shell
  • A 5 mm LED (forward voltage 2.0 V)
  • A 470 Ω resistor
  • A breadboard
  • Two female to male jumper wires

Construct the circuit as we have seen previously.

How to do it…

Once we have the construction, we can proceed with the steps given in the following sections.

Programming the LED with C

We start by programming the LED in the classic C programming language.

  1. Power on your Banana Pi.
  2. Open a shell.
  3. Create ...

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