Skip to content

Instantly share code, notes, and snippets.

@jensvaaben
Created April 20, 2014 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensvaaben/11110847 to your computer and use it in GitHub Desktop.
Save jensvaaben/11110847 to your computer and use it in GitHub Desktop.
Code for BeagleBone Black 4-bin binary LED counter
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