O'Reilly logo

Learning BeagleBone Python Programming by Alexander Hiam

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

Interactive GPIO

Let's take a look at how the GPIO pins can be controlled from Python's interactive interpreter. Enter the Python interpreter by running the python command without any arguments into a terminal (either in Cloud9 or in an SSH session), as shown in the following command:

root@beaglebone:/var/lib/cloud9# python
Python 2.7.3 (default, Mar 14 2014, 17:55:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Next, import everything from the PyBBIO library:

>>> from bbio import *

Now let's light one of the BeagleBone's on-board LEDs. Use the digitalWrite() function to set the GPIO output attached to the USR3 LED to its high level:

>>> digitalWrite(USR3, HIGH)

Take a look at USER LEDS closest ...

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