Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Beaglebone Python Programming

You're reading from  Learning Beaglebone Python Programming

Product type Book
Published in Jul 2015
Publisher
ISBN-13 9781784399702
Pages 196 pages
Edition 1st Edition
Languages

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 to the Ethernet connector on your BeagleBone, it should now be lit up, as shown in the following screenshot:

Go ahead and turn it off by setting it to a low state:

>>> digitalWrite(USR3, LOW)

Congratulations, you...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}