Commit a414056d authored by Federico Meloda's avatar Federico Meloda Committed by Aljaž Srebrnič

Fixed LED test

parent bba8f920
......@@ -2,37 +2,40 @@
from time import sleep
from random import randint
import configparser
import zmq
import spidev
import ws2812
c = 0
rand = 1
def get_color():
rand = randint(0, 10)
if rand < 5:
return (248, 255, 255)
elif rand == 6:
return (111, 255, 0)
elif rand == 7:
return (234, 255, 0)
elif rand == 8:
return (87, 255, 34)
global c
global rand
if c+rand > 80:
rand = randint(1, 8)*(-1)
return(80, 255, 0)
elif c+rand < 0:
rand = randint(1, 8)
return(0, 255, 0)
else:
return (0, 213, 0)
c = c + rand
return (c, 255, 0)
def light_flame():
spi = spidev.SpiDev()
spi.open(1, 0)
while True:
ws2812.write2812(spi, [get_color() * 4])
sleep(0.2)
sleep(0.001)
def main():
light_flame()
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment