Created
December 30, 2015 21:16
-
-
Save bee-san/30aca5803a3edc49834d to your computer and use it in GitHub Desktop.
Rainbow.py
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
#!/usr/bin/env python | |
import unicornhat as unicorn | |
import time, math, colorsys, random | |
print("Displaying the rainbows") | |
unicorn.brightness(0.3) | |
speed = 0.03 | |
offset = 30 | |
color_check = int(0) | |
r, g, b = random.randint(1,255), random.randint(1,255), random.randint(1,255) | |
def cooldown(unicorn): | |
for y in range(500, 0, -1): | |
time.sleep(0.001) | |
if y < 100: | |
y = "0.0" + str(y) | |
else: | |
y = "0." + str(y) | |
y = float(y) | |
unicorn.brightness(y) | |
unicorn.show() | |
while True: | |
unicorn.brightness(0.001) | |
for y in range(8): | |
for x in range(8): | |
unicorn.set_pixel(x,y,int(r),int(g),int(b)) | |
for x in range(0, 500): | |
time.sleep(0.001) | |
if x < 100: | |
x = "0.00" + str(x) | |
else: | |
x = "0." + str(x) | |
x = float(x) | |
unicorn.brightness(x) | |
unicorn.show() | |
time.sleep(5) | |
cooldown(unicorn) | |
r += 30 | |
if r >= 255: | |
r = random.randint(1,255) | |
g += 30 | |
if g >= 255: | |
g = random.randint(1,255) | |
b += 30 | |
if b >= 255: | |
b = random.randint(1,255) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment