O'Reilly logo

Programming the BeagleBone by Yogesh Chavan

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

Program to dance external LEDs

In Chapter 3, Blinking External LEDs we did a dancing LEDs exercise. We created an illusion light is traveling from one end to the other and from the other end back. Let's write a Python program to achieve the same. Connect seven LEDs with resistors as shown in Chapter 3. Type the following program in Cloud9, save it as dance_LEDs.py and run. You should be able to see light travelling to and fro from both ends.

This is the code for dance_LEDs.py:

#!/usr/bin/python import Adafruit_BBIO.GPIO as GPIO from time import sleep LED_pins = ["P8_7","P8_9","P8_11","P8_13","P8_15","P8_17","P8_19"] for led in LED_pins: GPIO.setup(led,GPIO.OUT) while True: for led in LED_pins: GPIO.output(led,GPIO.HIGH) sleep(0.1) GPIO.output(led,GPIO.LOW) ...

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