# Trinket Dotstar
from digitalio import *
import board
import adafruit_dotstar as dotstar
import time
numpix = 1
strip = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if (pos < 0):
return [0, 0, 0]
if (pos > 255):
return [0, 0, 0]
if (pos < 85):
return [int(pos * 3), int(255 - (pos*3)), 0]
elif (pos < 170):
pos -= 85
return [int(255 - pos*3), 0, int(pos*3)]
else:
pos -= 170
return [0, int(pos*3), int(255 - pos*3)]
def rainbow_cycle(wait):
for j in range(255):
for i in range(len(strip)):
idx = int ((i * 256 / len(strip)) + j)
strip[i] = wheel(idx & 255)
strip.show()
time.sleep(wait)
while True:
strip.fill([255, 0, 0])
strip.show()
time.sleep(1)
strip.fill([0, 255, 0])
strip.show()
time.sleep(1)
strip.fill([0, 0, 255])
strip.show()
time.sleep(1)
rainbow_cycle(0)
code to test the internal dotstar on trinket (or gemma)
if you are using https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_DotStar/master/adafruit_dotstar.py it works as expected
using the bundle mpy does not but no error, just doenst make the LED do the right thing :)
https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/tag/20170912
LED does flicker so something is happening?