Guest User

Untitled

a guest
Aug 19th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include "FastLED.h"
  2. #define NUM_LEDS1 10
  3. #define NUM_LEDS2 10
  4. #define NUM_LEDS3 10
  5. CRGB strip1[NUM_LEDS1];
  6. CRGB strip2[NUM_LEDS2];
  7. CRGB strip3[NUM_LEDS3];
  8.  
  9. // 1 sec. frequency
  10. unsigned long interval=1000; // the time we need to wait
  11. unsigned long previousMillis=0; // millis() returns an unsigned long.
  12.  
  13. // 5 sec. frequency
  14. unsigned long interval1=5000; // the time we need to wait
  15. unsigned long previousMillis1=0; // millis() returns an unsigned long.
  16.  
  17. void setup() {
  18. FastLED.addLeds<NEOPIXEL, 5>(strip1, NUM_LEDS1);
  19. FastLED.addLeds<NEOPIXEL, 6>(strip2, NUM_LEDS2);
  20. FastLED.addLeds<NEOPIXEL, 7>(strip3, NUM_LEDS3);
  21. }
  22.  
  23. void loop() {
  24. for(int i = 0; i < NUM_LEDS1; i++)
  25. for(int i = 0; i < NUM_LEDS2; i++)
  26. for(int i = 0; i < NUM_LEDS3; i++)
  27. // other CMD's...
  28. strip1[0] = CRGB::Red;
  29. strip2[0] = CRGB::Green;
  30. strip3[0] = CRGB::Blue;
  31. FastLED.show();
  32. strip1[0].fadeToBlackBy(255);
  33. strip2[0].fadeToBlackBy(255);
  34. strip3[0].fadeToBlackBy(255);
  35. FastLED.show();
  36. // replace delay(1000)
  37. if ((unsigned long)(millis() - previousMillis) >= interval) {
  38. previousMillis = millis();
  39. // every first second
  40. }
  41. // other CMD's...
  42. strip1[1] = CRGB::Red;
  43. strip2[1] = CRGB::Green;
  44. strip3[1] = CRGB::Blue;
  45. FastLED.show();
  46. strip1[1].fadeToBlackBy(255);
  47. strip2[1].fadeToBlackBy(255);
  48. strip3[1].fadeToBlackBy(255);
  49. FastLED.show();
  50.  
  51. // replace delay(5000)
  52. if ((unsigned long)(millis() - previousMillis1) >= interval1) {
  53. previousMillis1 = millis();
  54. // every fifth second
  55. // ...
  56. }
  57. // other CMD's...
  58. strip1[2] = CRGB::Red;
  59. strip2[2] = CRGB::Green;
  60. strip3[2] = CRGB::Blue;
  61. FastLED.show();
  62. strip1[2].fadeToBlackBy(255);
  63. strip2[2].fadeToBlackBy(255);
  64. strip3[2].fadeToBlackBy(255);
  65. FastLED.show();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment