Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import board
- import busio
- import neopixel
- from time import sleep
- from adafruit_circuitplayground.express import cpx
- pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=.01)
- uart = busio.UART(board.TX, board.RX, baudrate=115200)
- data = uart.read(2)
- cpx.red_led = True
- sleep(.5)
- cpx.red_led = False
- pixels[1] = (255, 255, 0)
- while True:
- data = uart.read(2)
- cpx.red_led = True
- sleep(.5)
- cpx.red_led = False
- sleep(.1)
- if data is not None:
- data_string = ''.join([chr(b) for b in data])
- # print(data_string, end="")
- count = int(data_string)
- if count <= 9:
- cpx.red_led = True
- for x in range(count):
- pixels[x] = (255, 0, 0)
- sleep(.05)
- pixels[count] = (0, 255, 0)
- cpx.red_led = False
- else:
- cpx.red_led = True
- sleep(.1)
- cpx.red_led = False
- sleep(.1)
- cpx.red_led = True
- for x in range(count % 10):
- pixels[x] = (255, 0, 0)
- sleep(.05)
- pixels[count % 10] = (0, 0, 255)
- count = count % 10
- cpx.red_led = False
- for x in range(count - 1, -1, -1):
- pixels[x] = (0, 0, 0)
- sleep(.05)
- sleep(.75)
- pixels.fill((0, 0, 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement