#include "FastLED.h"
// Matrix size
#define HEIGHT 16
#define WIDTH 16
#define NUM_LEDS WIDTH * HEIGHT
#define MATRIX_TYPE 1
#define DATA_PIN 3 // LEDs pin
#define BRIGHTNESS 255 // LED brightness
CRGB leds[NUM_LEDS]; // Define the array of leds
// ******************************************************************************
int offset = 0;
int offset2 = 0;
int offset3 = offset + offset2;
// ******************************************************************************
uint16_t XY (uint8_t x, uint8_t y) {
return (y * WIDTH + x);
}
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
pinMode(2, INPUT_PULLUP);
}
void loop() {
// ******************************************************************************
EVERY_N_MILLISECONDS(20) {
offset++;
offset2++;
offset3++;
}
EVERY_N_MILLISECONDS(20) {
offset3++;
}
int length = max(max(HEIGHT, WIDTH) / 20, 10);
int length2 = min(min(HEIGHT, WIDTH) / 50, 5);
for (uint16_t x = 0; x < HEIGHT; x++) {
for (uint16_t y = 0; y < WIDTH; y++) {
uint16_t i = XY(x, y);
if (x == 0 || x == HEIGHT - 1 || y == 0 || y == WIDTH - 1) {
leds[i] = CHSV(x * length + y * length + offset, 255, 255);
}
else if (x == 1 || x == HEIGHT - 2 || y == 1 || y == WIDTH - 2) {
leds[i] = CHSV(x * length + y * length + offset, 255, 255);
}
else if (x == HEIGHT / 2 - 1 || x == HEIGHT - HEIGHT / 2 ||
y == WIDTH / 2 - 1 || y == WIDTH - WIDTH / 2) {
leds[i] = CHSV(x * length + y * length + offset, 255, 255);
}
else {
leds[i] = CRGB::Black;
}
}
}
// ******************************************************************************
FastLED.show();
} //loop
FPS: 0
Power: 0.00W
Power: 0.00W