35 lines
1007 B
Python
35 lines
1007 B
Python
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||
|
from time import sleep as delay
|
||
|
import signal
|
||
|
import sys
|
||
|
import numpy
|
||
|
from time import perf_counter as millis
|
||
|
def sigint_handler(signal, frame):
|
||
|
print ('KeyboardInterrupt is caught')
|
||
|
board.shutdown()
|
||
|
sys.exit(0)
|
||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||
|
board = telemetrix_rpi_pico.TelemetrixRpiPico()
|
||
|
|
||
|
NUM_LEDS = 60
|
||
|
|
||
|
board.set_pin_mode_neopixel(pin_number=2,num_pixels=NUM_LEDS)
|
||
|
board.neopixel_clear(auto_show=True)
|
||
|
color = [[255,0,0],[255,127,0],[255,255,0],
|
||
|
[127,255,0],[0,255,0],[0,255,127],
|
||
|
[0,255,255],[0,127,255],[0,0,255],
|
||
|
[127,0,255],[255,0,255],[255,0,127]]
|
||
|
array = numpy.random.randint(low=0,high=9,size=60)
|
||
|
|
||
|
def updateLED():
|
||
|
for i in range(0,NUM_LEDS):
|
||
|
board.neo_pixel_set_value(i,r=color[array[i]][0],g=color[array[i]][1],b=color[array[i]][2])
|
||
|
board.neopixel_show()
|
||
|
|
||
|
while True:
|
||
|
array = numpy.random.randint(low=0,high=9,size=60)
|
||
|
updateLED()
|
||
|
delay(0.1)
|
||
|
|
||
|
board.shutdown()
|