Advertisement
allanGEE

FastLED Pulse With Alternating Colors IN PROGRESS 2016-11-28

Nov 28th, 2016
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. //
  2. // *********************************
  3. // **** TRYING TO FIGURE OUT ****
  4. // **** A PULSING PATTERN THAT ****
  5. // **** CHANGES COLOR BY ****
  6. // *** NESTING LOOPS *****
  7. // *********************************
  8. //
  9. // ******************
  10. // *** UNTESTED ***
  11. // ******************
  12. //
  13. #include "FastLED.h"
  14. #define DATA_PIN 8
  15. //#define CLK_PIN 4
  16. #define NUM_LEDS 12
  17. //
  18. CRGB leds[NUM_LEDS];
  19. //
  20. // *** NOTE TO SELF
  21. // Might not need the below three lines once sketch is tweaked.
  22. int pulseFade = 5; // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
  23. int pulseBrightness = 0;
  24. int pulseHue = 0; // Sets the initial color for the pulse effect to red.
  25. //
  26. void setup()
  27. {
  28. //
  29. delay(3000); // 3 second delay for recovery
  30. //
  31. //FastLED.setBrightness(96);
  32. //
  33. FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  34. //
  35. } // END OF VOID SETUP
  36. //
  37. void loop()
  38. //
  39. {
  40. for(int pulseHue = 0; pulseHue < 256; pulseHue = pulseHue + 32)// -- do I need +=32 ?
  41. {
  42. //
  43. for(int i = 0; i < NUM_LEDS; i++ )
  44. {
  45. leds[i] = CHSV(pulseHue, 255, 255);
  46. leds[i].fadeLightBy(pulseBrightness);
  47. }
  48. pulseBrightness = pulseBrightness + pulseFade;
  49. // reverse the direction of the fading at the ends of the fade:
  50. if(pulseBrightness == 0 || pulseBrightness == 255)
  51. {
  52. pulseFade = -pulseFade ;
  53. }
  54. //
  55. }
  56. FastLED.show(); //AS PER DANIEL GARCIA, TRY TO MOVE THESE TWO LINES ABOVE THE } JUST ABOVE
  57. delay(20); // This delay sets speed of the fade.
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement