How to Play With the Trinket M0
FleetingPlug the device, copy paste micropython uf2 code into its drive and start playing with mpremote.
Note that using circuitpython leads to having the code.py file always accessible, which is nicer.
blink the dotstar internal led.
The documentation of micropython says that configuring dotstar leds can be done using SoftSPI.
The tutorial from adafruit shows a configured example and the code of adafruit_dotstar
Therefore, we can infer the following code
import time
from machine import Pin, SoftSPI
spi = SoftSPI(
baudrate=4000000,
polarity=0,
phase=0,
sck=Pin.board.DOTSTAR_CLK,
mosi=Pin.board.DOTSTAR_DATA,
miso=Pin.board.MISO, # not used, but required
)
def dotstar_write(r, g, b, brightness=31):
start_frame = b"\x00\x00\x00\x00"
end_frame = b"\xff"
brightness = 0b11100000 | (brightness & 0b00011111)
led_frame = bytes([brightness, b, g, r])
spi.write(start_frame + led_frame + end_frame)
while True:
dotstar_write(255, 0, 0)
time.sleep(0.5)
dotstar_write(0, 255, 0)
time.sleep(0.5)
dotstar_write(0, 0, 255)
time.sleep(0.5)