#include <Arduino.h>
#include <FastLED.h>
#include <colorutils.h>
#define BRIGHTNESS 255 // maximum brightness is 255 on real leds this should probably be about 100
// the purpose of this application is to share the brightness between the
// four closest lights to the calculated position of each leaper
// this gives the feel of a display with many more pixels
// the technoligy is called anti-alliasing
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
// Define the LED matrix parameters
#define LED_PIN 3
#define NUM_LEDS_X 40
#define NUM_LEDS_Y 12
#define NUM_LEDS (NUM_LEDS_X * NUM_LEDS_Y)
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
}
void loop() {
// Draw a line on the LED matrix
for (int x = 0; x < 40; ++x) {
int y = x / 4;
if (y < NUM_LEDS_Y) {
leds[XY(x, y)] = CRGB::White;
}
}
FastLED.show();
delay(1000); // Adjust delay time as needed
fill_solid(leds, NUM_LEDS, CRGB::Black); // Clear the matrix
}
// Function to map 2D (x, y) coordinates to 1D LED array index
int XY(int x, int y) {
if (y % 2 == 0) {
// For even rows, return index directly
return y * NUM_LEDS_X + x;
} else {
// For odd rows, map x to reverse direction
return y * NUM_LEDS_X + (NUM_LEDS_X - 1 - x);
}
}