Beginner / 2–3 hours
Make some color with NeoPixel
Let's give those 50 LEDs something to do. The useful thing about an addressable LED is that you can choose its color independently. A red warning pixel can sit right beside a blue background without adding another control wire.
Install the basic matrix libraries from the CircuitPython page, then replace code.py with this program:
import time
import board
import neopixel
pixels = neopixel.NeoPixel(
board.NEOPIXEL, 50, brightness=0.05,
auto_write=False, pixel_order=neopixel.GRB
)
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 0, 0)]
while True:
for color in colors:
pixels.fill(color)
pixels.show()
time.sleep(1)
You should see red, green, blue, then darkness, each for about a second. A color is a tuple of three channel values: (red, green, blue). Each channel runs from 0 to 255. Red and green together make yellow; all zeros turn a pixel off.
pixel_order=neopixel.GRB describes how the LED expects bytes on the wire. You still write your tuples in RGB order. If the red and green tests are swapped on your board revision, confirm the fitted LED's color order and adjust this argument.
brightness scales the output. Keep it low while experimenting; changing every pixel to white increases the load even if the brightness setting stays the same. auto_write=False lets us prepare a complete frame before show() sends it. Without that, drawing a pattern could transmit after every individual pixel assignment. The NeoPixel reference describes the pixel object and its options.
Find pixel zero
The display looks like a rectangle, but the library sees indices 0 through 49. Replace code.py with this walking-pixel test:
import time
import board
import neopixel
pixels = neopixel.NeoPixel(
board.NEOPIXEL, 50, brightness=0.05,
auto_write=False, pixel_order=neopixel.GRB
)
while True:
for index in range(50):
pixels.fill((0, 0, 0))
pixels[index] = (255, 60, 0)
pixels.show()
print("Pixel", index)
time.sleep(0.2)
Watch where the light starts and how it crosses a row boundary. Hold the board so the rows run horizontally, with ten pixels across and five down. For our logical coordinates, the pixel-zero corner is (0, 0) and increasing x follows the first row. Increasing y moves to the next row.
The existing S3 example uses sequential rows: 0–9, 10–19, and so on, with each row running in the same direction. Check that with the walking test on your board. If alternating rows run backward, you have a serpentine layout and need the alternate mapping described below. Rotating the board changes where the picture appears, not the electrical indices.
Draw with coordinates
Here's a complete moving-column program using the sequential-row map:
import time
import board
import neopixel
WIDTH = 10
HEIGHT = 5
pixels = neopixel.NeoPixel(
board.NEOPIXEL, WIDTH * HEIGHT, brightness=0.05,
auto_write=False, pixel_order=neopixel.GRB
)
def xy(x, y):
return y * WIDTH + x
column = 0
while True:
pixels.fill((0, 0, 0))
for row in range(HEIGHT):
pixels[xy(column, row)] = (0, 120, 255)
pixels.show()
column = (column + 1) % WIDTH
time.sleep(0.15)
xy(3, 2) returns 23: skip two rows of ten, then move three pixels along. The % WIDTH operation wraps column ten back to zero. You should see a blue column travel across the matrix and start again.
If your walking test showed alternating row directions, replace only xy() with:
def xy(x, y):
if y % 2:
x = WIDTH - 1 - x
return y * WIDTH + x
Use the mapping you verified in later projects too. Coordinates must stay within 0–9 for x and 0–4 for y.
Try lighting just the four corners. Then draw a border, or make the moving column change color each time it wraps. Small patterns are a useful way to catch a mapping mistake before you build something more complicated.
When the result looks wrong
If nothing lights, look at the serial console first, confirm the firmware exposes board.NEOPIXEL, and return to the red/green/blue test. If updates don't appear, check that you called show(). A broken-looking column usually means the coordinate mapping doesn't match the wiring. Resets when more pixels light point toward a power or cable issue; reduce brightness and the lit-pixel count.