import board
import neopixel
import time
import random
LED_PIN = board.GP0 # Data pin for the Neopixel strip/matrix
NUM_LEDS = 100
WIDTH = 10
HEIGHT = 10
pixels = neopixel.NeoPixel(LED_PIN, NUM_LEDS, brightness=0.5, auto_write=False)
def xy_to_index(x, y):
if y % 2 == 0: # Even row (0-indexed)
return y * 10 + x
else: # Odd row
return y * 10 + (9 - x) # Assuming 10 LEDs per row
def random_color():
return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
def visualize():
for row in range(HEIGHT):
row_color = random_color() # Different color for each row
for x in range(WIDTH):
index = xy_to_index(x, row)
pixels[index] = row_color # Apply the color
pixels.show()
while True:
visualize()
time.sleep(0.1) # Simulate audio changes quickly