Operating a Red-Green-Blue (RGB) LED strip that uses APA102 LEDs.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/29210c2f-35bd-4e4e-ae0b-52322c3d32b0/Untitled.png

⚙ Hardware Needed


📚 External Libraries Needed


adafruit_dotstar.mpy

📑 Code


import board
import adafruit_dotstar as dotstar

# Length of LED strip
length=30

# DotStar(CLK, DATA)
dots = dotstar.DotStar(board.D31, board.D35, length, brightness=0.1, auto_write=False)
for dot in range(length):
    dots[dot] = (255,255,255) # white
dots.show()

Details


🔌 If you're using a SAM32 and have the common APA102 strips that require 5V, you can use the SAM32's VIN pin to provide power to the strip (assuming the board is plugged in to a typical 5V USB port).

<aside> 🚨 Careful! LED strips can draw a lot of current! ⚡

As a rule of thumb, estimate that each LED on your strip draws 60 mA (when emitting white light and a brightness=1).

Standard USB ports can supply 500mA, which means less than 10 LEDs

</aside>

Another option for powering the strips is to use a screw-terminal type barrel jack connector 👉. This lets you use an external power supply (make sure it's 5V). You can attached this directly to 5V and GND on one end of the strip, and power the SAM32 by connecting 5V to VIN and GND to GND on the other end.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f31c26e3-6f57-4976-8912-0e2c10e8fae9/Untitled.png

Links

For LED strips, I prefer ones like these:

Adafruit DotStar Digital LED Strip - White 144 LED/m - One Meter

Barrel jack:

Female DC Power adapter - 2.1mm jack to screw terminal block