// from: https://forum.makerforums.info/t/anyone-using-the-attiny85-chip-with-fastled/60733
#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 106
CRGB strip[NUM_LEDS];
byte mode;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(strip, NUM_LEDS); // setup the strip
mode = 0;
}
void loop() {
// Some example procedures showing how to display to the pixels:
switch (mode)
{
case 0:
colorWipe(0x7f0000, 25); // Red
colorWipe(0x7f7f00, 25); // Yellow
colorWipe(0x007f00, 25); // Green
colorWipe(0x007f7f, 25); // Cyan
colorWipe(0x00007f, 25); // Blue
colorWipe(0xff007f, 25); // Magenta
break;
case 1:
// Send a theater pixel chase in…
theaterChase(0x7f7f7f, 25); // White
theaterChase(0x7f0000, 25); // Red
theaterChase(0x007f00, 25); // Green
theaterChase(0x00007f, 25); // Blue
break;
case 2:
colorSnake(0x7f0000, 10, 25); // Red
colorSnake(0x7f7f00, 10, 25); // Yellow
colorSnake(0x007f00, 10, 25); // Green
colorSnake(0x007f7f, 10, 25); // Cyan
colorSnake(0x00007f, 10, 25); // Blue
colorSnake(0xff007f, 10, 25); // Magenta
break;
default:
mode = -1;
}
mode++;
}
void colorWipe(uint32_t c, uint8_t wait) {
for (int i = 0; i < NUM_LEDS; i++) {
strip[i] = c;
FastLED.show();
delay(wait);
}
}
void colorSnake(uint32_t c, int length, uint8_t wait)
{
for (int i = 0; i < NUM_LEDS + length; i++)
{
if (i < NUM_LEDS) {
strip[i] = c;
}
if (i - length >= 0) {
strip[i - length] = 0;
}
FastLED.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
int i, j, q;
for (j = 0; j < 10; j++) { //do 10 cycles of chasing
for (q = 0; q < 3; q++) {
for (i = 0; i < NUM_LEDS - q; i = i + 3) {
strip[i + q] = c; //turn every third pixel on
}
FastLED.show();
delay(wait);
for (i = 0; i < NUM_LEDS - q; i = i + 3) {
strip[i + q] = 0; //turn every third pixel off
}
}
}
}