Skip to content

Instantly share code, notes, and snippets.

@chrisy
Last active December 26, 2015 18:29
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 chrisy/7195296 to your computer and use it in GitHub Desktop.
Save chrisy/7195296 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import spidev
import time
speed = 1000000
bpw = 8
spi = spidev.SpiDev()
spi.open(0,0)
spi.bits_per_word = bpw
spi.lsbfirst = False
spi.mode = 0
spi.max_speed_hz = speed
count=100
r=0
g=96
b=192
def f(v):
l = v % 256
o = int(v / 256)%2
if o == 0: return l
return 255-l
while True:
p = []
for i in range(count):
p.append(f(r+i))
p.append(f(g+i))
p.append(f(b+i))
spi.xfer2(p, speed, 500, bpw)
r += 9
g += 5
b += 3
time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment