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...