Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define NUM_LEDS1 10
- #define NUM_LEDS2 10
- #define NUM_LEDS3 10
- CRGB strip1[NUM_LEDS1];
- CRGB strip2[NUM_LEDS2];
- CRGB strip3[NUM_LEDS3];
- // 1 sec. frequency
- unsigned long interval=1000; // the time we need to wait
- unsigned long previousMillis=0; // millis() returns an unsigned long.
- // 5 sec. frequency
- unsigned long interval1=5000; // the time we need to wait
- unsigned long previousMillis1=0; // millis() returns an unsigned long.
- void setup() {
- FastLED.addLeds<NEOPIXEL, 5>(strip1, NUM_LEDS1);
- FastLED.addLeds<NEOPIXEL, 6>(strip2, NUM_LEDS2);
- FastLED.addLeds<NEOPIXEL, 7>(strip3, NUM_LEDS3);
- }
- void loop() {
- for(int i = 0; i < NUM_LEDS1; i++)
- for(int i = 0; i < NUM_LEDS2; i++)
- for(int i = 0; i < NUM_LEDS3; i++)
- // other CMD's...
- strip1[0] = CRGB::Red;
- strip2[0] = CRGB::Green;
- strip3[0] = CRGB::Blue;
- FastLED.show();
- strip1[0].fadeToBlackBy(255);
- strip2[0].fadeToBlackBy(255);
- strip3[0].fadeToBlackBy(255);
- FastLED.show();
- // replace delay(1000)
- if ((unsigned long)(millis() - previousMillis) >= interval) {
- previousMillis = millis();
- // every first second
- }
- // other CMD's...
- strip1[1] = CRGB::Red;
- strip2[1] = CRGB::Green;
- strip3[1] = CRGB::Blue;
- FastLED.show();
- strip1[1].fadeToBlackBy(255);
- strip2[1].fadeToBlackBy(255);
- strip3[1].fadeToBlackBy(255);
- FastLED.show();
- // replace delay(5000)
- if ((unsigned long)(millis() - previousMillis1) >= interval1) {
- previousMillis1 = millis();
- // every fifth second
- // ...
- }
- // other CMD's...
- strip1[2] = CRGB::Red;
- strip2[2] = CRGB::Green;
- strip3[2] = CRGB::Blue;
- FastLED.show();
- strip1[2].fadeToBlackBy(255);
- strip2[2].fadeToBlackBy(255);
- strip3[2].fadeToBlackBy(255);
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment