Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //***************************************************************
- // The main code here was created by Mark Miller, Jan 2019
- // Modified By MoBacon2400 Aug. 2021 to run on multiple strips
- // Each strip can be modified separately for different effects, color, speed and number of LEDs per strip.
- #include "FastLED.h" // FastLED library.
- #define NUM_LED_STRIP_1 16
- #define NUM_LED_STRIP_2 16
- #define NUM_LED_STRIP_3 16
- #define NUM_LEDS_TOTAL 48
- //#define BRIGHTNESS 125
- #define LED_PIN_A 8
- #define LED_PIN_B 6
- #define LED_PIN_C 4
- #define LED_TYPE WS2812B
- //#define MASTER_BRIGHTNESS 160
- CRGB ledsA[NUM_LED_STRIP_1];
- CRGB ledsB[NUM_LED_STRIP_2];
- CRGB ledsC[NUM_LED_STRIP_3];
- uint8_t max_bright = 255;
- //Strip 1----------------------------------------------------------------
- // Set initial start position of each color
- int16_t positionA1 = NUM_LED_STRIP_1*2/3;
- int16_t positionB1 = NUM_LED_STRIP_1/3;
- int16_t positionC1 = 0;
- const uint16_t holdTimeX = 100; // Adjusts speed of travel
- int8_t delta1 = 1; // 1 or -1. Sets travel direction
- //Strip 2----------------------------------------------------------------
- // Set initial start position of each color
- int16_t positionA2 = NUM_LED_STRIP_2*2/3;
- int16_t positionB2 = NUM_LED_STRIP_2/3;
- int16_t positionC2 = 0;
- const uint16_t holdTimeY = 80; // Adjusts speed of travel
- int8_t delta2 = -1; // 1 or -1. Sets travel direction
- //Strip 3--------------------------------------------------------------------
- // Set initial start position of each color
- int16_t positionA3 = NUM_LED_STRIP_3*2/4;
- int16_t positionB3 = NUM_LED_STRIP_3/3;
- int16_t positionC3 = 0;
- const uint16_t holdTimeZ = 120; // Adjusts speed of travel
- int8_t delta3 = 1; // 1 or -1. Sets travel direction
- //---------------------------------------------------------------
- void setup() {
- delay( 3000 ); // power-up safety delay
- FastLED.addLeds<LED_TYPE, LED_PIN_A, GRB>(ledsA, NUM_LED_STRIP_1);
- FastLED.addLeds<LED_TYPE, LED_PIN_B, GRB>(ledsB, NUM_LED_STRIP_2);
- FastLED.addLeds<LED_TYPE, LED_PIN_C, GRB>(ledsC, NUM_LED_STRIP_3);
- FastLED.setBrightness(max_bright);
- }
- //---------------------------------------------------------------
- void loop() {
- EVERY_N_MILLISECONDS(holdTimeX) {
- strip_1();
- }
- EVERY_N_MILLISECONDS(holdTimeY) {
- strip_2();
- }
- EVERY_N_MILLISECONDS(holdTimeZ) {
- strip_3();
- }
- FastLED.show(); // Show the pixels
- }
- //-----------------------------------------------------------------------
- void strip_1(){
- // Fading tail effect. Comment out for solid colors
- fadeToBlackBy( ledsA, NUM_LED_STRIP_1, 200);
- // assign pixel colors
- ledsA[positionA1] = CRGB::Purple;
- ledsA[positionB1] = CRGB::Gray; // Using grey so not as bright
- ledsA[positionC1] = CRGB::Navy;
- // FastLED.show(); // Show the pixels
- // Advance position based on delta, and rollover if needed.
- positionA1 = ((positionA1 + delta1 + NUM_LED_STRIP_1) % NUM_LED_STRIP_1);
- positionB1 = ((positionB1 + delta1 + NUM_LED_STRIP_1) % NUM_LED_STRIP_1);
- positionC1 = ((positionC1 + delta1 + NUM_LED_STRIP_1) % NUM_LED_STRIP_1);
- }//end every_n
- //----------------------------------------------------------------------------------
- void strip_2(){
- // Fading tail effect. Comment out for solid colors
- fadeToBlackBy( ledsB, NUM_LED_STRIP_2, 100);
- // assign pixel colors
- ledsB[positionA2] = CRGB::Cyan;
- ledsB[positionB2] = CRGB::Gray; // Using grey so not as bright
- ledsB[positionC2] = CRGB::Orange;
- // FastLED.show(); // Show the pixels
- // Advance position based on delta, and rollover if needed.
- positionA2 = ((positionA2 + delta2 + NUM_LED_STRIP_2) % NUM_LED_STRIP_2);
- positionB2 = ((positionB2 + delta2 + NUM_LED_STRIP_2) % NUM_LED_STRIP_2);
- positionC2 = ((positionC2 + delta2 + NUM_LED_STRIP_2) % NUM_LED_STRIP_2);
- }//end every_n
- //-------------------------------------------------------------------------------------
- void strip_3(){
- // Fading tail effect. Comment out for solid colors
- fadeToBlackBy( ledsC, NUM_LED_STRIP_3, 220);
- // assign pixel colors
- ledsC[positionA3] = CRGB::Blue;
- ledsC[positionB3] = CRGB::Gray; // Using grey so not as bright
- ledsC[positionC3] = CRGB::Red;
- // FastLED.show(); // Show the pixels
- // Advance position based on delta, and rollover if needed.
- positionA3 = ((positionA3 + delta3 + NUM_LED_STRIP_3) % NUM_LED_STRIP_3);
- positionB3 = ((positionB3 + delta3 + NUM_LED_STRIP_3) % NUM_LED_STRIP_3);
- positionC3 = ((positionC3 + delta3 + NUM_LED_STRIP_3) % NUM_LED_STRIP_3);
- }//end every_n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement