Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Banana Pi Cookbook
  • Table Of Contents Toc
Banana Pi Cookbook

Banana Pi Cookbook

By : RYAD E DAJANI, Ryad El-Dajani
4.5 (2)
close
close
Banana Pi Cookbook

Banana Pi Cookbook

4.5 (2)
By: RYAD E DAJANI, Ryad El-Dajani

Overview of this book

This book is intended for anybody who wants to learn how they can utilize the capabilities of the Banana Pi to its full potential. It's full of step-by-step guides and detailed descriptions for the whole range of possibilities in a language that is appropriate for computer enthusiasts and experts alike. It would be helpful to have a basic knowledge of Unix-like operating systems or programming, but no prior experience is required as every concept is explained in the appropriate sections.
Table of Contents (8 chapters)
close
close

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 a source code directory and change location to it:
    $ mkdir ~/source
    $ cd ~/source
    
  4. Create a source file using nano:
    $ nano led_test.c
    
  5. The nano editor will open. Write the following code in C:
    #include <wiringPi.h>
    
    int main(void...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Banana Pi Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon