chemdoc77

Using the fill_solid and fill_rainbow functions

May 1st, 2016
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. // Testing the CRGBSet array function and using it with the fill_solid and fill_rainbow functions.
  2. // by Chemdoc77
  3.  
  4. #include "FastLED.h"
  5. #define NUM_LEDS 24
  6. #define Data_Pin 6
  7.  
  8. CRGB rawleds[NUM_LEDS];
  9. CRGBSet leds(rawleds, NUM_LEDS);
  10. CRGBSet leds1(leds(0,7));
  11. CRGBSet leds2(leds(8,15));
  12. CRGBSet leds3(leds(16,23));
  13.  
  14. struct CRGB * ledsarry[] ={leds1, leds2, leds3};
  15.  
  16. void setup() {
  17. delay(2000); // power-up safety delay
  18. FastLED.addLeds<NEOPIXEL, Data_Pin>(leds, NUM_LEDS);
  19. FastLED.setBrightness(40);
  20.  
  21. }
  22. void loop() {
  23.  
  24. fill_solid(ledsarry[0], 8, CHSV( 213, 255, 255)); //8 is number of elements in the array
  25. FastLED.show();
  26. delay(700);
  27. fill_solid( ledsarry[0], 8, CRGB::Black);
  28. FastLED.show();
  29.  
  30. fill_solid(ledsarry[1], 8, CRGB::Green);
  31. FastLED.show();
  32. delay(700);
  33. fill_solid( ledsarry[1], 8, CRGB::Black);
  34. FastLED.show();
  35.  
  36. fill_solid(ledsarry[2], 8, CRGB::Blue);
  37. FastLED.show();
  38. delay(700);
  39. fill_solid( ledsarry[2], 8, CRGB::Black);
  40. FastLED.show();
  41.  
  42. fill_rainbow( ledsarry[0], 8, 0, 10);
  43. FastLED.show();
  44. delay(700);
  45. fill_solid( ledsarry[0], 8, CRGB::Black);
  46. FastLED.show();
  47.  
  48. fill_rainbow( ledsarry[1], 8, 80, 10);
  49. FastLED.show();
  50. delay(700);
  51. fill_solid( ledsarry[1], 8, CRGB::Black);
  52. FastLED.show();
  53.  
  54. fill_rainbow( ledsarry[2], 8, 180, 20);
  55. FastLED.show();
  56. delay(700);
  57. fill_solid( ledsarry[2], 8, CRGB::Black);
  58. FastLED.show();
  59.  
  60. cd77_arrayfill(CRGB::Blue, 700);
  61. cd77_arrayfill(CRGB::Red, 700);
  62. }
  63. //================ New Function =====================
  64.  
  65. void cd77_arrayfill(CRGB color, uint16_t wait){
  66.  
  67. for (uint8_t x=0; x<3; x++){
  68. fill_solid(ledsarry[x], 8, color);
  69. FastLED.show();
  70. delay(wait);
  71. fill_solid( ledsarry[x], 8, CRGB::Black);
  72. FastLED.show();
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment