#include <FastLED.h>
#include "frames.h"
#define LED_PIN 5
#define WIDTH 16
#define HEIGHT 16
#define NUM_LEDS (WIDTH*HEIGHT)
CRGB leds[NUM_LEDS];
// Mapping zig-zag matrix
uint16_t XY(uint8_t x, uint8_t y) {
if (y % 2 == 0) {
return (y * WIDTH) + x;
} else {
return (y * WIDTH) + (WIDTH - 1 - x);
}
}
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
}
void loop() {
static int frame = 0;
// copy frame ke buffer
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
leds[XY(x,y)] = frames[frame][y*WIDTH + x];
}
}
FastLED.show();
frame = (frame + 1) % NUM_FRAMES;
delay(100); // speed animasi
}