Skip to content

Instantly share code, notes, and snippets.

/Dotstar2.py Secret

Created November 17, 2017 21:00
Show Gist options
  • Save anonymous/aceb92a6e0a21a6a5a6c3072652cf391 to your computer and use it in GitHub Desktop.
Save anonymous/aceb92a6e0a21a6a5a6c3072652cf391 to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
import time
scl = 16
sda = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(scl, GPIO.OUT)
GPIO.setup(sda, GPIO.OUT)
def clock():
GPIO.output(scl, GPIO.HIGH)
#time.sleep(.05)
GPIO.output(scl, GPIO.LOW)
def startFrame():
count = 0
GPIO.output(sda, GPIO.LOW)
while count < 32:
clock()
count = count + 1
def endFrame():
count = 0
GPIO.output(sda, GPIO.HIGH)
while count < 32:
clock()
count = count + 1
def startLedFrame():
count = 0
GPIO.output(sda, GPIO.HIGH)
while count < 3:
clock()
count = count + 1
def commandBrightness():
GPIO.output(sda, GPIO.LOW)
clock()
clock()
GPIO.output(sda, GPIO.HIGH)
clock()
def commandRed():
count = 0
GPIO.output(sda, GPIO.LOW)
while count < 16:
clock()
count = count + 1
count = 0
GPIO.output(sda, GPIO.HIGH)
while count < 8:
clock()
count = count + 1
def commandLeds():
led = 0
leds = 30
while led < leds:
startLedFrame()
commandBrightness()
commandRed()
led = led +1
def setPinsLow():
GPIO.output(sda, GPIO.LOW)
GPIO.output(scl, GPIO.LOW)
startFrame()
commandLeds()
endFrame()
setPinsLow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment