Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FastLED Setup
- #define FASTLED_INTERNAL
- #include "FastLED.h"
- #define LEDstrips 28
- #define LEDper 60
- #define LEDtype WS2813
- #define LEDcorr TypicalSMD5050
- #define LEDdither 255 //try 0 to reduce flickering
- uint8_t LEDbright = 10;
- int LEDamps = 3000;
- CRGB leds[LEDstrips][LEDper];
- CRGBPalette16 dynamicpal;
- uint8_t hue = 155;
- bool palshuffle = false;
- //String BLEupfactors[] = {"bright", "amps", "speed", "bpm"};
- //String BLEupdata[] = {LEDbright, LEDamps, STATEloopinterval, bpm};
- byte rotator = 0;
- int8_t blendspeed = 24;
- /////////////////////////////////////////////////////////////////////////////
- DECLARE_GRADIENT_PALETTE( borderrainbow ){
- 0, 0, 0, 0,
- 115, 255, 0, 0,
- 185, 0, 255, 0,
- 255, 0,0,255 };
- DECLARE_GRADIENT_PALETTE( purplecascade ){ //GRB
- 0, 0, 0, 0, //black
- 120, 155, 0, 255, //purple
- 235, 255, 0, 40, //crimson
- 255, 255, 255, 255 }; //full white
- DECLARE_GRADIENT_PALETTE( blackwhite ){
- 0, 0, 0, 0,
- 127, 0, 0, 0,
- 128, 255, 255, 255,
- 255, 255, 255, 255};
- DECLARE_GRADIENT_PALETTE( newspaper ){
- 0, 0, 0, 0,
- 127, 0, 0, 0,
- 128, 255, 255, 255,
- 255, 255, 0, 0};
- DECLARE_GRADIENT_PALETTE( sunburst ){
- 0, 0, 0, 0,
- 120, 255, 255, 0,
- 235, 255, 255, 255,
- 255, 255, 255, 255};
- DECLARE_GRADIENT_PALETTE( gilt ){
- 0, 0, 0, 0,
- 128, 96, 0, 140,
- 150, 255, 100, 0,
- 235, 255, 200, 0,
- 255, 255, 255, 255};
- DECLARE_GRADIENT_PALETTE( tropicana ){
- 0, 0, 0, 0,
- 71, 66, 245, 230,
- 145, 255, 255, 255,
- 255, 245, 66, 203};
- DEFINE_GRADIENT_PALETTE( startup ){ //RYGCB
- 0, 255, 0, 0, //red
- 51, 255, 0, 0,
- 52, 255, 255, 0, //yellow
- 102, 255, 255, 0,
- 103, 0, 255, 0, //green
- 153, 0, 255, 0,
- 154, 0, 255, 255, //cyan
- 205, 0, 255, 255,
- 206, 0, 0, 255, //blue
- 255, 0, 0, 255};
- const TProgmemPalette16 redyell_p PROGMEM = {
- 0, 0, 0, 0,
- 120, 240,0,0,
- 235, 255, 200, 0,
- 255, 255,255,255};
- CRGBPalette16 currentPalette(CRGB::Black);
- CRGBPalette16 targetPalette(CRGB::Black);
- void setup() {
- // Initialize LEDs
- FastLED.setMaxPowerInVoltsAndMilliamps(5,LEDamps); //play with the order here
- //FastLED.setTemperature();
- FastLED.setBrightness(LEDbright);
- FastLED.setDither(LEDdither);
- FastLED.addLeds<LEDtype, PIN_C4, GRB>(leds[0], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C3, GRB>(leds[1], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C2, GRB>(leds[2], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C1, GRB>(leds[3], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C0, GRB>(leds[4], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E1, GRB>(leds[5], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E0, GRB>(leds[6], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D7, GRB>(leds[7], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D6, GRB>(leds[8], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D5, GRB>(leds[9], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D4, GRB>(leds[10], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D1, GRB>(leds[11], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D0, GRB>(leds[12], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B7, GRB>(leds[13], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B4, GRB>(leds[14], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B3, GRB>(leds[15], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B2, GRB>(leds[16], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B1, GRB>(leds[17], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B0, GRB>(leds[18], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E7, GRB>(leds[19], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E6, GRB>(leds[20], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F0, GRB>(leds[21], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F1, GRB>(leds[22], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F2, GRB>(leds[23], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F3, GRB>(leds[24], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F4, GRB>(leds[25], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F5, GRB>(leds[26], LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F6, GRB>(leds[27], LEDper).setCorrection(LEDcorr);
- FastLED.clear();
- FastLED.show();
- Serial.begin(9600);
- }
- void loop() {
- fillleds();
- if(palshuffle == true){
- nblendPaletteTowardPalette( currentPalette, targetPalette, blendspeed);
- nblendPaletteTowardPalette( currentPalette, targetPalette, blendspeed);
- } else {
- currentPalette = targetPalette;
- }
- if(palshuffle == true){
- EVERY_N_SECONDS(10){
- palettetargeting(random8(17));
- }
- }
- EVERY_N_SECONDS(10){
- Serial.print("FPS: ");
- Serial.print(LEDS.getFPS());
- Serial.print(" Target: ");
- //Serial.print(paltarget);
- Serial.println();
- }
- //hue++;
- FastLED.show();
- }
- void fillleds(){
- if(palshuffle == false){
- palettetargeting(8);
- }
- CRGBPalette16 palette = redyell_p;
- for(uint8_t x = 0; x < LEDstrips; x++){
- for(uint8_t y = 0; y < LEDper; y++){
- leds[x][y] = ColorFromPalette(palette, hue + y*8, 255, LINEARBLEND);
- }
- }
- }
- void palettetargeting(uint8_t paltarget){ // Select which palette to blend to
- switch(paltarget){
- case 0:
- targetPalette = startup;
- break;
- case 1:
- targetPalette = purplecascade;
- break;
- case 2:
- targetPalette = blackwhite;
- break;
- case 3:
- targetPalette = newspaper;
- break;
- case 4:
- targetPalette = sunburst;
- break;
- case 5:
- targetPalette = gilt;
- break;
- case 6:
- targetPalette = tropicana;
- break;
- case 7:
- targetPalette = borderrainbow;
- break;
- case 8:
- targetPalette = redyell_p;
- break;
- case 9:
- targetPalette = RainbowColors_p;
- break;
- case 10:
- targetPalette = RainbowStripeColors_p;
- break;
- case 11:
- targetPalette = CloudColors_p;
- break;
- case 12:
- targetPalette = PartyColors_p;
- break;
- case 13:
- targetPalette = LavaColors_p;
- break;
- case 14:
- targetPalette = OceanColors_p;
- break;
- case 15:
- targetPalette = ForestColors_p;
- break;
- case 16:
- targetPalette = HeatColors_p;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement