#include <FastLED.h>
// Matrix size
#define LED_COLS 16
#define LED_ROWS 16
#define NUM_LEDS LED_COLS * LED_ROWS
// LEDs pin
#define DATA_PIN 4
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setBrightness(255);
}
#define INCR 85
void AddB(uint16_t i)
{
if (leds[i].b + INCR > 255)
{
leds[i].b = 0;
AddG(i);
}
else
leds[i].b += INCR;
}
void AddG(uint16_t i)
{
if (leds[i].g + INCR > 255)
{
leds[i].g = 0;
AddR(i);
}
else
leds[i].g += INCR;
}
void AddR(uint16_t i)
{
if (leds[i].r + INCR > 255)
{
leds[i].r = 0;
AddB(i + 1);
}
else
leds[i].r += INCR;
}
void loop() {
AddB(0);
FastLED.show();
}