94 lines
2 KiB
Arduino
94 lines
2 KiB
Arduino
|
/* FastLED RGBW Example Sketch
|
||
|
*
|
||
|
* Example sketch using FastLED for RGBW strips (SK6812). Includes
|
||
|
* color wipes and rainbow pattern.
|
||
|
*
|
||
|
* Written by David Madison
|
||
|
* http://partsnotincluded.com
|
||
|
*/
|
||
|
|
||
|
#include "FastLED.h"
|
||
|
#include "FastLED_RGBW.h"
|
||
|
|
||
|
#define NUM_LEDS1 150
|
||
|
#define NUM_LEDS2 150
|
||
|
#define NUM_LEDS3 300 // tira virtual que no se pinta
|
||
|
#define DATA_PIN_1 8
|
||
|
#define DATA_PIN_2 3
|
||
|
#define DATA_PIN_3 4 // tira virtual que no se pinta, en este pin fastled no funciona
|
||
|
|
||
|
CRGBW leds1[NUM_LEDS1];
|
||
|
CRGBW leds2[NUM_LEDS2];
|
||
|
CRGBW leds3[NUM_LEDS3]; // TUBO TOTAL, ESTE NO SE PINTA, SOLO SE GENERA Y LOS OTROS SE COPIAN DE ESTE
|
||
|
CRGB *ledsRGB1 = (CRGB *) &leds1[0];
|
||
|
CRGB *ledsRGB2 = (CRGB *) &leds2[0];
|
||
|
CRGB *ledsRGB3 = (CRGB *) &leds3[0];
|
||
|
|
||
|
const uint8_t brightness = 255;
|
||
|
|
||
|
void setup() {
|
||
|
FastLED.addLeds<SK6812, DATA_PIN_1, RGB>(ledsRGB1, getRGBWsize(NUM_LEDS1));
|
||
|
FastLED.addLeds<SK6812, DATA_PIN_2, RGB>(ledsRGB2, getRGBWsize(NUM_LEDS2));
|
||
|
FastLED.addLeds<SK6812, DATA_PIN_3, RGB>(ledsRGB3, getRGBWsize(NUM_LEDS3));
|
||
|
FastLED.setBrightness(brightness);
|
||
|
FastLED.show();
|
||
|
}
|
||
|
|
||
|
void loop(){
|
||
|
colorFill(CRGB::Red);
|
||
|
colorFill(CRGB::Green);
|
||
|
colorFill(CRGB::Blue);
|
||
|
fillWhite();
|
||
|
rainbowLoop();
|
||
|
}
|
||
|
|
||
|
void splitStrip()
|
||
|
{
|
||
|
for ( int i = 0; i < NUM_LEDS1 ; i++)
|
||
|
{
|
||
|
leds1[i] = leds3[i];
|
||
|
leds2[i] = leds3[i+NUM_LEDS1];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void colorFill(CRGB c){
|
||
|
for(int i = 0; i < NUM_LEDS3; i++){
|
||
|
leds3[i] = c;
|
||
|
splitStrip(); // realmente hace falta generar todo en una tira entera y partirla?
|
||
|
FastLED.show();
|
||
|
delay(2);
|
||
|
}
|
||
|
delay(500);
|
||
|
}
|
||
|
|
||
|
void fillWhite(){
|
||
|
for(int i = 0; i < NUM_LEDS3; i++){
|
||
|
leds3[i] = CRGBW(0, 0, 0, 255);
|
||
|
splitStrip();
|
||
|
FastLED.show();
|
||
|
delay(2);
|
||
|
}
|
||
|
delay(500);
|
||
|
}
|
||
|
|
||
|
void rainbow(){
|
||
|
static uint8_t hue;
|
||
|
|
||
|
for(int i = 0; i < NUM_LEDS3; i++){
|
||
|
leds3[i] = CHSV((i * 256 / NUM_LEDS3) + hue, 255, 255);
|
||
|
}
|
||
|
splitStrip();
|
||
|
FastLED.show();
|
||
|
hue++;
|
||
|
}
|
||
|
|
||
|
void rainbowLoop(){
|
||
|
long millisIn = millis();
|
||
|
long loopTime = 5000; // 5 seconds
|
||
|
|
||
|
while(millis() < millisIn + loopTime){
|
||
|
rainbow();
|
||
|
delay(1);
|
||
|
}
|
||
|
}
|