// Two WS2812
// https://forum.arduino.cc/t/how-would-i-safely-connect-2-sets-of-2-3-leds-to-a-nano-without-using-an-external-power-source/1446334/43
#include <FastLED.h> // https://github.com/FastLED/FastLED
#define PIX 2 // number of WS2812
#define PIN 6 // data pin
CRGB led[PIX]; // FastLED object (led[])
#define maximum 255 // set maximum brightness for each LED (0 - 255)
bool i, state;
int buttonPin = 2, count, fullcount = 1;
unsigned long timer, timeout = 5000;
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // LOW when PRESSED, HIGH when RELEASED
FastLED.addLeds<WS2812, PIN, GRB>(led, PIX);
FastLED.clear();
FastLED.setBrightness(maximum);
FastLED.show();
while (digitalRead(buttonPin) == HIGH) {}; // do nothing until button pressed
}
void loop() {
if (millis() - timer > timeout) {
timer = millis();
if (count++ == fullcount)
count = 0;
FastLED.clear();
FastLED.show();
}
count = 0;
switch (count) {
case 0: blend(); break;
default: break;
}
}
void blend() {
for (int i = 0; i < 256; i++) {
led[0] = CRGB(i, i, 255); // increase from blu to wht
led[1] = CRGB(255 - i, 255 - i, 255); // decrease from wht to blu
FastLED.show();
delay(10);
}
for (int i = 0; i < 256; i++) {
led[0] = CRGB(255 - i, 255 - i, 255);
led[1] = CRGB(i, i, 255);
FastLED.show();
delay(10);
}
}
void onetwo() {
led[0] = CRGB::White;
FastLED.show();
delay(2000);
led[0] = CRGB::Blue;
FastLED.show();
delay(2000);
}
void flicker() {
led[0] = CRGB::Red;
FastLED.show();
delay(50);
led[0] = CRGB::Green;
FastLED.show();
delay(75);
}
void blinkblonk() {
if (i)
led[0] = CRGB(0, 0, 255);
else
led[0] = CRGB(255, 255, 255);
FastLED.show();
delay(500);
led[0] = CRGB(0, 0, 0);
FastLED.show();
delay(500);
i = !i;
}
void wigwag(int r1, int g1, int b1, int r2, int g2, int b2) {
int myDelay = 1000;
if (state) {
led[0] = CRGB(r1, g1, b1);
FastLED.show();
delay(50);
led[0] = CRGB(r2, g2, b2);
FastLED.show();
delay(50);
led[0] = CRGB(r1, g1, b1);
FastLED.show();
delay(500);
} else {
led[0] = CRGB(r2, g2, b2);
FastLED.show();
delay(50);
led[0] = CRGB(r1, g1, b1);
FastLED.show();
delay(50);
led[0] = CRGB(r2, g2, b2);
FastLED.show();
delay(500);
}
state = !state;
delay(myDelay);
}
void ramp() {
int myDelay = 10; // 10ms = 4sec
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 256; i++) {
if (j)
led[0] = CRGB(i, i, i); // white
else
led[0] = CRGB(0, 0, i); // blue
FastLED.show();
delay(myDelay);
}
}
}
void updown() {
int myDelay = 10; // 10ms = 10sec
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 256; i++) {
if (j)
led[0] = CRGB(i, i, i); // white
else
led[0] = CRGB(0, 0, i); // blue
FastLED.show();
delay(myDelay);
}
for (int i = 0; i < 256; i++) {
if (j)
led[0] = CRGB(255 - i, 255 - i, 255 - i); // white
else
led[0] = CRGB(0, 0, 255 - i); // blue
FastLED.show();
}
delay(myDelay);
}
}PRESS