Python Reference
Neopixel grid
NeoPixel WS2812B 8×8 Grid
Wiring:
| Grid Terminal | Connect To |
|---|---|
| 5V or VCC | 5V (external supply recommended for full brightness) |
| GND | GND (same GND as ESP32) |
| DIN (Data In) | GPIO 6 |
Power note: 64 LEDs at full white draw ~3.8A. For testing, keep brightness low (max ~50 per channel). For full brightness, use an external 5V power supply rated at 4A or more. Always connect GND of the external supply to the ESP32's GND.
Pixel numbering: Pixels are numbered 0–63, left-to-right, top-to-bottom:
0 1 2 3 4 5 6 7 ← Row 0 (top)
8 9 10 11 12 13 14 15 ← Row 1
16 17 18 19 20 21 22 23 ← Row 2
...
56 57 58 59 60 61 62 63 ← Row 7 (bottom)
Formula: index = row * 8 + col
Code:
import machine
import neopixel
pin = machine.Pin(6, machine.Pin.OUT)
np = neopixel.NeoPixel(pin, 64)
def clear():
for i in range(64):
np[i] = (0, 0, 0)
np.write()
def set_pixel(row, col, r, g, b):
np[row * 8 + col] = (r, g, b)
def render():
np.write()
# Example: light up top-left corner
clear()
set_pixel(0, 0, 255, 0, 0) # Red at row 0, col 0
render()
Did you know? Each WS2812B LED in your grid contains its own tiny control chip. The data signal is passed from LED to LED in a chain — that's why you only need one data wire for all 64 LEDs.