Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (34 sloc) 776 Bytes
import sys
import random
from random import randint
import time
from sense_hat import SenseHat
sense=SenseHat()
sense.clear()
r = 255
g = 0
b = 0
msleep = lambda x: time.sleep(x / 1000.0)
def next_colour():
global r,g,b
if (r == 255 and g < 255 and b == 0):
g += 1
if (g == 255 and r > 0 and b == 0):
r -= 1
if (g == 255 and b < 255 and r == 0):
b += 1
if (b == 255 and g > 0 and r == 0):
g -= 1
if (b == 255 and r < 255 and g == 0):
r += 1
if (r == 255 and b > 0 and g == 0):
b -= 1
while True:
try:
sense.clear([r, g, b])
msleep(.5)
next_colour()
except KeyboardInterrupt:
sense.clear()
sys.exit()
#////////////////////////////////
You can’t perform that action at this time.