Python / Mac OS X
Nothing fancy, but just sharing what I've done with my blinkytape since I got it last Thursday. You'll notice that some of this code is redundant, but was just playin around with Python and seeing what I could come up with.
from BlinkyTape import BlinkyTape
import urllib2
import re
from time import sleep
import random
import math
from datetime import datetime
now = datetime.now()
hour = int(now.hour)
min = int(now.minute)
if int(hour) > 12:
hour = int(hour) - 12
bb = BlinkyTape('/dev/tty.usbmodem1441') #least on Mac OS X, this is the port to use!
def leftright():
for y in range(60):
for x in range(60):
r = ((x-y) % 60)
g = ((x-y) % 60)
b = (x-y) % 60
bb.sendPixel(r,g%25,g%255)
bb.show()
for y in (range(60)):
for x in range(60):
r = ((x+y) % 60)
g = ((x+y) % 60)
b = (x+y) % 60
bb.sendPixel(g%20,g,0)
bb.show()
def seg():
for y in range(60):
for x in range(60):
if x <= 20:
r = ((x-y) % 60)*3
g = ((x+y) % 20)*3
b = (x-y) % 30 * 3
bb.sendPixel(r,g,b)
elif x >= 21 and x <= 40:
r = ((x-y) % 60)*2
g = ((x+y) % 20)*2
b = (x-y) % 30 * 2
bb.sendPixel(r,g,b)
else:
r = ((x+y) % 40)*3
g = ((x-y) % 60)*3
b = (x+y) % 30*3
bb.sendPixel(r,g,b)
bb.show()
def flasher(flash):
for y in range(60)[::flash]:
for x in range(60):
if x <= 30:
bb.sendPixel((y+x)% 60,0,0)
else:
bb.sendPixel(0,0,(y-x)% 60)
bb.show()
for y in range(60)[::flash]:
for x in range(60):
if x <= 30:
bb.sendPixel(0,0,(y-x)% 60 * 3,)
else:
bb.sendPixel((y+x)% 60 * 3,0,0)
bb.show()
def exposure():
for j in range(10):
for x in reversed(range(60)):
for y in range(60):
if y < 55:
y = y + 200
r = (x-y) % 20 * 11
bb.sendPixel(r, j*2 ,j*20)
bb.show()
for k in range(255)[::100]:
for j in range(60):
bb.sendPixel(100,100,255)
bb.show()
def backstep():
for x in range(60):
for y in range(60):
sleep(0.0001)
r = (x+y) % 255
if y == x:
bb.sendPixel(255,r/2,r/2)
x = x + 1
else:
bb.sendPixel(r*2,r%120,0)
bb.show()
for x in reversed(range(60)):
for y in range(60):
sleep(0.001)
r = (x+y) % 255
if y == x:
bb.sendPixel(0,r/2,255)
x = x + 1
else:
bb.sendPixel(r*2,r%120,0)
bb.show()
def clock():
for x in range(60):
if x >= min:
bb.sendPixel(0,0,0)
elif x == hour - 1:
bb.sendPixel(255,255,255)
else:
bb.sendPixel(150,0,20)
bb.show()
def freqy(frequency):
for i in range(60):
red = int(math.sin(frequency*i + 0) * 127 + 128)
green = int(math.sin(frequency*i + 2) * 127 + 128)
blue = int(math.sin(frequency*i + 4) * 127 + 128)
for j in range(60):
if j <= i:
bb.sendPixel(red,green,blue)
else:
bb.sendPixel(0,0,0)
bb.show()
for i in range(60):
red = int(math.sin(frequency*i + 0) * 127 + 128)
green = int(math.sin(frequency*i + 2) * 127 + 128)
blue = int(math.sin(frequency*i + 4) * 127 + 128)
for j in range(60):
if j >= i:
bb.sendPixel(red,green,blue)
else:
bb.sendPixel(0,0,0)
bb.show()
def scanner():
for i in range(1):
for x in range(60):
red = int(math.sin(0.1*x + 6) * 127 + 128)
for y in range(60):
l = max(((y - x) % 60) - 40, 0)
bb.sendPixel(red, l * 3, l * 9)
bb.show()
for i in range(1):
for x in range(60):
red = int(math.sin(0.1*x + 2) * 127 + 128)
for y in range(60):
l = max(((y + x) % 60) - 40, 0)
bb.sendPixel(red, l*7, l * 3)
bb.show()
def purplebounce():
for x in reversed(range(100)):
for y in reversed(range(60)):
l = max(((x - y) % 60)-40, 0)
print l
bb.sendPixel(l*3,0,l*4)
bb.show()
for x in reversed(range(100)):
for y in reversed(range(60)):
l = max(((y + x) % 60)-40, 0)
print l
bb.sendPixel(l*3,l*4,l*4)
bb.show()
def knightrider():
for x in range(75):
for y in range(60):
r = int(math.sin(0.1 * x + -15) * 127 + 128)
z = [y+i for i in range(15)]
if x == x in z:
bb.sendPixel(r,0,0)
else:
bb.sendPixel(0,0,0)
bb.show()
for x in reversed(range(75)):
for y in range(60):
r = int(math.sin(0.1 * x + -15) * 127 + 128)
z = [y+i for i in range(15)]
if x == x in z:
bb.sendPixel(r,0,0)
else:
bb.sendPixel(0,0,0)
bb.show()
while True:
for x in range(20):
flasher(10)
for x in range(2):
leftright()
for x in range(3):
seg()
for x in range(2):
exposure()
for x in range(3):
backstep()
for x in range(5):
freqy(0.2)
for x in range(5):
scanner()
for x in range(5):
purplebounce()
for x in range(5):
knightrider()