Created
April 20, 2014 10:36
-
-
Save jensvaaben/11110847 to your computer and use it in GitHub Desktop.
Code for BeagleBone Black 4-bin binary LED counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Adafruit_BBIO.GPIO as GPIO | |
import time | |
def setled(i): | |
print i | |
if((i&0x1)==0x1): | |
GPIO.output("P8_26",GPIO.HIGH) | |
else: | |
GPIO.output("P8_26",GPIO.LOW) | |
if((i&0x2)==0x2): | |
GPIO.output("P9_23",GPIO.HIGH) | |
else: | |
GPIO.output("P9_23",GPIO.LOW) | |
if((i&0x4)==0x4): | |
GPIO.output("P9_15",GPIO.HIGH) | |
else: | |
GPIO.output("P9_15",GPIO.LOW) | |
if((i&0x8)==0x8): | |
GPIO.output("P8_13",GPIO.HIGH) | |
else: | |
GPIO.output("P8_13",GPIO.LOW) | |
def bbled(): | |
GPIO.setup("P8_26", GPIO.OUT) | |
GPIO.setup("P9_23", GPIO.OUT) | |
GPIO.setup("P9_15", GPIO.OUT) | |
GPIO.setup("P8_13", GPIO.OUT) | |
for i in range(16): | |
setled(i%16 ) | |
time.sleep(1) | |
if __name__ == "__main__": | |
bbled() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment