I'm having trouble getting SPI to drive Dotstars using the Metro M4 Express and Circuitpython. I can get them to work on D5 and D6 using the bitbanging code, but not the SPI code (nothing happens at all). The only changes I'm making are the data/clock wires between D5/D6 and MOSI/SCK and uncommenting the appropriate definition. Can anyone suggest some troubleshooting to try or see what I'm doing wrong? Thanks! P.S. I'm using a level shifter.
I have an external power supply for the strip and am getting the clock from the SCK pin and data from the MOSI pin on the 6 pin header according to the pinout of: https://learn.adafruit.com/adafruit-met ... 51/pinouts I'm using the circuitpython code from the dotstar tutorial found at https://learn.adafruit.com/adafruit-dot ... ibrary-use
Code: Select all
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import random
import board
import adafruit_dotstar as dotstar
# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
# dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
# HELPERS
# a random color 0 -> 192
def random_color():
return random.randrange(0, 7) * 32
# MAIN LOOP
n_dots = len(dots)
while True:
# Fill each dot with a random color
for dot in range(n_dots):
dots[dot] = (random_color(), random_color(), random_color())
#time.sleep(0.001)