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

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 Run and you should see the LED turn on for half a second, turn off for half a second, and repeat forever. Alright! When you're done watching the light show you can press the Stop button or hit Ctrl + C in the terminal that opened when...

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 €14.99/month. Cancel anytime}