blob: 8ed3130ce0722dc7e134028c6cc578a26981d550 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
""" Imports """
import smbus
import time
import i2cPixel
""" Decalrations """
pixels = 10
addresses = [0, 24, 25, 35] # legg til en start og en stopp for hvert trinn
def hexToRgb(value):
value = value.lstrip('#')
lv = len(value)
return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
def lightStaircase(direction):
repeats = len(addresses)
repeats = repeats / 2
if direction = "up":
loopCondition = repeats
while loopCondition >> pixels
else:
loopCondition = 0
return true
def main():
""" Setup i2c communication """
i2cPixel.version()
i2cPixel.setBus(1)
i2cPixel.setAddress(0x04)
""" Wait for heartbeat from Arduino """
while True:
try:
if i2cPixel.greeting():
print "Arduino is Online"
break
except Exception:
pass
"""while True:
i2cPixel.waitForSensor()"""
""" Test, set all pixels to entered color """
while True:
test = raw_input()
colour = hexToRgb(test)
i = 0
while i < 10:
i2cPixel.setPixel(i, colour[0], colour[1], colour[2])
i = i + 1
i2cPixel.show()
i2cPixel.waitForSensor()
""" Start script """
main()
|