#include "FastLED.h"
// Set the dimensions of the matrix
const int matrixWidth = 18;
const int matrixHeight = 6;
// Set the number of LEDs in the strip and the pin they are connected to
const int numLeds = matrixWidth * matrixHeight;
const int ledPin = 2;
CRGB leds[numLeds];
// Set the frequency and amplitude of the sine wave
const float frequency = 0.09;
const float amplitude = 125;
void setup() {
// Initialize the LED strip
FastLED.addLeds<NEOPIXEL, ledPin>(leds, numLeds);
Serial.begin(9600);
}
bool animationRun = false;
void loop() {
// Calculate the sine wave and apply it to the LED matrix
int painx = 4;
int painy = 4;
for (int y = 0; y < matrixHeight; y++) {
for (int x = 0; x < matrixWidth; x++) {
int i = y * matrixWidth + x;
int distance = abs(painy - x) + abs(painx - y);
leds[i] = CHSV(i, 255, (int)(amplitude * sin(frequency * distance - millis() / 1000.0) + 128));
}
}
// Update the LED strip
FastLED.show();
// Sleep for a short time to create the animation effect
delay(10);
}