#include <FastLED.h>
#define NUM_LEDS 5 /* The amount of pixels/leds you have */
#define DATA_PIN_A 3 /* The pin your data line is connected to */
#define DATA_PIN_B 4
#define LED_TYPE WS2812B /* I assume you have WS2812B leds, if not just change it to whatever you have */
#define BRIGHTNESS 255 /* Control the brightness of your leds */
#define SATURATION 127 /* Control the saturation of your leds */
CRGB leds[NUM_LEDS];
void setup() {
pinMode (2, INPUT); /* high for color cycling, low for fixed colors */
FastLED.addLeds<LED_TYPE, DATA_PIN_A>(leds, NUM_LEDS);
FastLED.addLeds<LED_TYPE, DATA_PIN_B>(leds, NUM_LEDS);
}
void loop() {
while (digitalRead(2)); {
for (int j = 0; j < 255; j++) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(i - (j * 2), BRIGHTNESS, SATURATION); /* The higher the value 4 the less fade there is and vice versa */
}
FastLED.show();
delay(30); /* Change this to your hearts desire, the lower the value the faster your colors move (and vice versa) */
}
// blue to DATA_PIN_A
// yellow to DATA_PIN_B
while (!digitalRead(2)); { //basically stop loop until pin 2 is back high
}
}
}
Rough code. It works but I was hoping someone could explain how to:
drive LEDs on DATA_PIN_B at a different color (say, 180° from those on A)
and to set A to blue and B to yellow when pin 2 is low.