Skip to content

Instantly share code, notes, and snippets.

@ranbogmord
Created December 6, 2015 14:42
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 ranbogmord/178a00a7fec22fa42c46 to your computer and use it in GitHub Desktop.
Save ranbogmord/178a00a7fec22fa42c46 to your computer and use it in GitHub Desktop.
Blink random lights
from subprocess import call
from time import sleep
from random import randint
device_name = "hw:1"
loop_through = [
00, 01, 02, 03, 04, 05, 06, 07,
10, 11, 12, 13, 14, 15, 16, 17,
20, 21, 22, 23, 24, 25, 26, 27,
30, 31, 32, 33, 34, 35, 36, 37,
40, 41, 42, 43, 44, 45, 46, 47,
50, 51, 52, 53, 54, 55, 56, 57,
60, 61, 62, 63, 64, 65, 66, 67,
70, 71, 72, 73, 74, 75, 76, 77
]
colors = [
"0F", "3F", "3E", "3C"
]
while True:
slots = []
cs = []
for i in range(0, 10):
slots.append(randint(0, len(loop_through) - 1))
cs.append(colors[randint(0, 3)])
for j in range(0, len(slots)):
call(["amidi", "-p", device_name, "-S", "90 " + str(loop_through[slots[j]]) + " " + cs[j]])
sleep(0.02)
for j in range(0, len(slots)):
call(["amidi", "-p", device_name, "-S", "90 " + str(loop_through[slots[j]]) + " 0C"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment