// https://www.reddit.com/r/FastLED/comments/16b75d7/diagonal_candycane_fx_on_3_x_30_grid/
#include "FastLED.h"
// serpentine layout of 32 strips each with 3 LEDs
CRGBArray<96> leds;
CRGBSet strips[] = {
leds(0, 2), leds(5, 3), leds(6, 8), leds(11, 9), leds(12, 14),
leds(17, 15), leds(18, 20), leds(23, 21), leds(24, 26), leds(29, 27),
leds(30, 32), leds(35, 33), leds(36, 38), leds(41, 39), leds(42, 44),
leds(47, 45), leds(48, 50), leds(53, 51), leds(54, 56), leds(59, 57),
leds(60, 62), leds(65, 63), leds(66, 68), leds(71, 69), leds(72, 74),
leds(77, 75), leds(78, 80), leds(83, 81), leds(84, 86), leds(89, 87),
leds(90, 92), leds(95, 93),
};
void setup() {
FastLED.addLeds<NEOPIXEL, 3>(leds, leds.size());
}
void loop() {
uint8_t widthRed = 8;
uint8_t widthWhite = 8;
// animate the speed of animation slowly over time. To allow fine
// control of speed, the units are 1/256ths of pixel per frame.
int16_t speed = (sin8(millis() / 64) - 128) / 2;
// move the start position on each frame
static uint16_t basePos = 0;
basePos += speed;
// switch units from 1/256ths of pixel to 1 pixel
uint16_t stripPos = basePos / 256;
for (CRGBSet& strip : strips) {
// offset the start of each strip by 1 pixel to get diagonal stripes
stripPos += 1;
uint16_t pixPos = stripPos;
for (CRGB& pixel : strip) {
pixPos += 1;
// use the Modulus operator to determine the colour for this pixel
if (pixPos % (widthRed + widthWhite) < widthRed) {
pixel = CRGB::Red;
} else {
pixel = CRGB::White;
}
}
}
FastLED.show();
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
neopixels1:DOUT
neopixels1:VDD
neopixels1:VSS
neopixels1:DIN
FPS: 0
Power: 0.00W
Power: 0.00W