#include <FastLED.h>
#define ROWS 16
#define COLS 16
#define N_LEDS (ROWS*COLS)
CRGB leds[N_LEDS];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
FastLED.addLeds<WS2812B, 12, GRB>(leds, N_LEDS);
}
// Your pattern code goes here.
// This draw() function is called repeatedly and the LEDs will be
// printed after every loop.
//
// Some helpful variables:
// ROWS: number of rows
// COLS: number of columns
// N_LEDS: total number of LEDs (LED_COLS * LED_ROWS)
// leds: the LED array to print to
//
// You can also use:
// uint16_t gridIndexHorizontal(x, y) - the index of a given x/y coordinate
// uint8_t beatsin8(bpm, minimum, maximum, offset) - an 8-bit sine wave
//
// For more information, visit https://github.com/FastLED/FastLED/wiki/Overview
void draw() {
static uint8_t off = 0;
for(uint8_t i = 0; i<COLS; i++) {
for(uint8_t j = 0; j<ROWS; j++){
//int k = gridIndexHorizontal(i,j);
int k = i * COLS + j;
uint8_t t = beatsin8(20*256, N_LEDS/4, N_LEDS/4*3); // Move 1/4 to 3/4
leds[k] = CHSV(uint8_t(t*3+i*16+j*16+off), 255, 255);
}
}
off++;
}
void loop() {
FastLED.delay(10); // this speeds up the simulation
draw();
}