#include <FastLED.h>
// Define the LED matrix properties
#define LED_MATRIX_WIDTH 8
#define LED_MATRIX_HEIGHT 8
#define LED_PIN 3
// Set the LED matrix type and color order if needed
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
// Define the LED array
CRGB leds[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT];
void setup() {
// Initialize FastLED with the LED properties
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT);
}
void loop() {
rainbowArtEffect();
}
// Function to create the rainbow art
void rainbowArtEffect() {
static uint8_t hue = 0;
// Iterate through each LED and set the color based on the current hue
for (int y = 0; y < LED_MATRIX_HEIGHT; y++) {
for (int x = 0; x < LED_MATRIX_WIDTH; x++) {
// Calculate the index of the current LED
int ledIndex = xyToIndex(x, y);
// Set the color of the current LED
leds[ledIndex] = CHSV(hue + x * 8, 155, 255);
}
}
// Show the LED colors
FastLED.show();
// Increment the hue for the next frame
hue += 5;
delay(350); // Adjust the delay to control the speed of the animation
}
// Function to convert (x, y) coordinates to an index in the LED array
int xyToIndex(int x, int y) {
if (y % 2 == 0) {
return y * LED_MATRIX_WIDTH + x;
} else {
return y * LED_MATRIX_WIDTH + (LED_MATRIX_WIDTH - x - 1);
}
}
FPS: 0
Power: 0.00W
Power: 0.00W