Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. // Testing FastLED's CRGBSet array with a fill the whole array function and with a colorwipe function
  2. // by Chemdoc77
  3.  
  4. #include "FastLED.h"
  5. #define NUM_LEDS 24
  6. #define Data_Pin 6
  7. #define chipset NEOPIXEL
  8. #define BRIGHTNESS 50
  9.  
  10.  
  11. CRGB rawleds[NUM_LEDS];
  12. CRGBSet leds(rawleds, NUM_LEDS);
  13. CRGBSet leds1(leds(0,7));
  14. CRGBSet leds2(leds(8,15));
  15. CRGBSet leds3(leds(16,23));
  16.  
  17. struct CRGB * ledarray[] ={leds1, leds2, leds3}; // An array of the CRGBSet arrays
  18.  
  19. uint8_t sizearray[]= {8,8,8}; // size of the above arrays
  20. void setup() {
  21. delay(2000); // power-up safety delay
  22. FastLED.addLeds<chipset, Data_Pin>(leds, NUM_LEDS);
  23. FastLED.setBrightness(BRIGHTNESS);
  24. FastLED.setMaxPowerInVoltsAndMilliamps(5,1500);
  25. set_max_power_indicator_LED(13);
  26. }
  27. void loop() {
  28. // fills the whole array
  29. CD77_arrayfill(CRGB::Blue, 700);
  30. CD77_arrayfill(CRGB::Red, 700);
  31. // Fills one dot at a time
  32. CD77_colorwipe_dot(0, CRGB::Blue, 200);
  33. CD77_colorwipe_dot(1, CRGB::Red, 200);
  34. CD77_colorwipe_dot(2, CRGB::Green, 200);
  35. }
  36. //================ New Functions =====================
  37.  
  38. void CD77_colorwipe_dot(uint8_t y, CRGB color, uint32_t wait) { //Note: y is ledarray number
  39. for (uint8_t x = 0; x < sizearray[y]; x++) {
  40. ledarray[y][x] = color;
  41. FastLED.delay(wait);
  42. ledarray[y][x] =CRGB::Black;
  43. }
  44. }
  45. void CD77_arrayfill(CRGB color, uint16_t wait){
  46.  
  47. for (uint8_t x=0; x<3; x++){
  48. fill_solid(ledarray[x], sizearray[x], color);
  49. FastLED.show();
  50. delay(wait);
  51. fill_solid( ledarray[x], sizearray[x], CRGB::Black);
  52. FastLED.show();
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement