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

Blink

Now that we have our transistor driving the LED at its full current from GPIO0_30 (P9.11), let's use Adafruit_BBIO to write a program that blinks it at a fixed interval. The first step is to load the universal-io Device Tree overlay as described previously:

# echo cape-universaln > /sys/devices/bone_capemgr.*/slots

Next you'll need to use the config-pin command to manually configure the pin as a digital output:

# config-pin P9_11 in

Now that the pin is configured properly, open a new file in Cloud9 called blink.py with the following code:

from Adafruit_BBIO import GPIO
import time

LED_PIN = "GPIO0_30"
GPIO.setup(LED_PIN, GPIO.OUT)

while True:
  GPIO.output(LED_PIN, GPIO.HIGH)
  time.sleep(0.5)
  GPIO.output(LED_PIN, GPIO.LOW)
  time.sleep(0.5)

Press ...

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