#include "FastLED.h"
// Matrix size
#define HEIGHT 32
#define WIDTH 32
#define NUM_LEDS HEIGHT * WIDTH
#define MATRIX_TYPE 1
// LEDs pin
#define DATA_PIN 3
// LED brightness
#define BRIGHTNESS 255
// Define the array of leds
CRGB leds[NUM_LEDS];
//// ----------------------------- Spider ------------------------------
//(c)stepko
#define Speed 250
#define Koef 9 //1,3,5,7,9(standart),10,12
#define lines 7
#define Color 1 //By Kostyamat https://editor.soulmatelights.com/gallery/550
#define Fader 30 //By Kostyamat https://editor.soulmatelights.com/gallery/550
#define sx ((256 / (WIDTH / 2)) - (WIDTH / 16))
#define cy ((256 / (HEIGHT / 2)) - (HEIGHT / 16))
void drawLine(int x1, int y1, int x2, int y2,
const CRGB & color) {
int deltaX = abs(x2 - x1);
int deltaY = abs(y2 - y1);
int signX = x1 < x2 ? 1 : -1;
int signY = y1 < y2 ? 1 : -1;
int error = deltaX - deltaY;
leds[XY(x2, y2)] += color;
while (x1 != x2 || y1 != y2) {
leds[XY(x1, y1)] += color;
int error2 = error * 2;
if (error2 > -deltaY) {
error -= deltaY;
x1 += signX;
}
if (error2 < deltaX) {
error += deltaX;
y1 += signY;
}
}
}
void draw() {
fadeToBlackBy(leds, NUM_LEDS, Fader);
double t = millis() / (256 - Speed);
for (uint8_t c = 0; c < lines; c++) {
byte xx = sin8(t + (100 * c) * Koef) / sx;
byte yy = cos8(t + (150 * c) * Koef) / cy;
if (Color)
drawLine(xx, yy, WIDTH - xx - 1, HEIGHT - yy - 1, CHSV(c * (256 / lines), 200, 255));
else
drawLine(xx, yy, WIDTH - xx - 1, HEIGHT - yy - 1, CHSV(0, 0, 255));
}
blur2d(leds, WIDTH, HEIGHT, 32);
delay(16);
}
void setup() {
//Serial.begin(250000);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
draw();
FastLED.show();
} //loop
uint16_t XY (uint8_t x, uint8_t y) {
if(x<0||x>= WIDTH || y<0 || y >= HEIGHT) return;
if ((y % 2 == 0) || MATRIX_TYPE) // если чётная строка
{
return ((uint32_t)y *WIDTH + x) % (WIDTH * HEIGHT);
}
else // если нечётная строка
{
return ((uint32_t)y * HEIGHT + WIDTH - x - 1) % (WIDTH * HEIGHT);
}
}
uno:SCL
uno:SDA
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:14
uno:15
uno:16
uno:17
uno:18
uno:19
uno:20
uno:21
uno:5V.1
uno:5V.2
uno:22
uno:23
uno:24
uno:25
uno:26
uno:27
uno:28
uno:29
uno:30
uno:31
uno:32
uno:33
uno:34
uno:35
uno:36
uno:37
uno:38
uno:39
uno:40
uno:41
uno:42
uno:43
uno:44
uno:45
uno:46
uno:47
uno:48
uno:49
uno:50
uno:51
uno:52
uno:53
uno:GND.4
uno:GND.5
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
uno:A6
uno:A7
uno:A8
uno:A9
uno:A10
uno:A11
uno:A12
uno:A13
uno:A14
uno:A15
neopixels:DOUT
neopixels:VDD
neopixels:VSS
neopixels:DIN