Book Image

BeagleBone Black Cookbook

Book Image

BeagleBone Black Cookbook

Overview of this book

There are many single-board controllers and computers such as Arduino, Udoo, or Raspberry Pi, which can be used to create electronic prototypes on circuit boards. However, when it comes to creating more advanced projects, BeagleBone Black provides a sophisticated alternative. Mastering the BeagleBone Black enables you to combine it with sensors and LEDs, add buttons, and marry it to a variety of add-on boards. You can transform this tiny device into the brain for an embedded application or an endless variety of electronic inventions and prototypes. With dozens of how-tos, this book kicks off with the basic steps for setting up and running the BeagleBone Black for the first time, from connecting the necessary hardware and using the command line with Linux commands to installing new software and controlling your system remotely. Following these recipes, more advanced examples take you through scripting, debugging, and working with software source files, eventually working with the Linux kernel. Subsequently, you will learn how to exploit the board's real-time functions. We will then discover exciting methods for using sound and video with the system before marching forward into an exploration of recipes for building Internet of Things projects. Finally, the book finishes with a dramatic arc upward into outer space, when you explore ways to build projects for tracking and monitoring satellites.
Table of Contents (16 chapters)
BeagleBone Black Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Running a Python script to control the LEDs


In the next chapter, we'll look at more robust ways to begin using the GPIO pin library. In the meantime, let's wrap up by doing an on board LED blink similar to the recipe we did earlier in the chapter.

However, instead of BoneScript, we'll do a variation of the recipe in Python and specifically pull on the PyBBIO library's functionality. This recipe will work on both Debian Wheezy and Jessie.

How to do it…

Perform the following steps to run Python scripts to control LEDs:

  1. Open up LXTerminal.

  2. Create a python project directory within the bbb_recipe_book directory and navigate to it as follows:

    mkdir python
    cd bbb_recipe_book/projects/python
    
  3. Create a new Python file using the following code (note the .py file format):

    sudo nano major_tom_blinks.py
    
  4. Copy and paste the following code into the window:

    #!/usr/bin/python
    
    # Blinks one of the Beaglebone Black's on-board LEDs until CTRL-C is pressed. These LEDs include USR0, USR1, USR2, USR3
    
    # Import PyBBIO...