Guest User

CupHeadFlickerBug

a guest
Oct 18th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. // How many leds are in the strip?
  4. #define numLeds 144
  5.  
  6. #define pin1 10
  7. #define pin2 11
  8. #define pin3 9
  9.  
  10. #define strip1 65
  11. #define strip2 62
  12. #define strip3 17
  13.  
  14. // This is an array of leds.  One item for each led in your strip.
  15. CRGB leds[numLeds];
  16.  
  17. #define numRows 9
  18. byte stripLens[numRows] = {3, 9, 14, 18, 21, 23, 22, 19, 15};
  19. byte stripStart[numRows] = {0, 3, 12, 26, 44, 65, 88, 110, 129};
  20.  
  21.  
  22. // This function sets up the ledsand tells the controller about them
  23. void setup() {
  24. // sanity check delay - allows reprogramming if accidently blowing power w/leds
  25.     delay(2000);
  26.  
  27.       FastLED.addLeds<WS2812B, pin1, GRB>(leds, strip1);
  28.       FastLED.addLeds<WS2812B, pin2, GRB>(leds, strip1, strip2);
  29.       FastLED.addLeds<WS2812B, pin3, GRB>(leds, strip1 + strip2, strip3);
  30.       set_max_power_in_volts_and_milliamps( 5, 3000);
  31.       FastLED.setDither( 0 );
  32.       FastLED.setBrightness(255);
  33. }
  34.  
  35. void setAllColor(CRGB color)
  36. {
  37.   byte curLed = numLeds;  
  38.   while(curLed--)
  39.   {
  40.     leds[curLed] = color;
  41.   }
  42. }
  43.  
  44. void debugBlink (CRGB color)
  45. {
  46.   setAllColor(color);
  47.   FastLED.show();
  48.   delay(50);  
  49. }
  50.  
  51. // This function runs over and over, and is where you do the magic to light
  52. // your leds.
  53. void loop() {
  54.   static uint8_t hue = 0;
  55.  
  56.   debugBlink(CRGB::Red);  // flash a color so I can tell which is which
  57.   // this is rock solid
  58.   setAllColor(CRGB::White);
  59.   FastLED.show();
  60.   FastLED.delay(3000);
  61.  
  62.   debugBlink(CRGB::Blue);   // flash a color so I can tell which is which
  63.   // this is rock solid
  64.   setAllColor(CRGB::White);
  65.   FastLED.show();
  66.   delay(3000);
  67.  
  68.   debugBlink(CRGB::Green);    // flash a color so I can tell which is which
  69.   // lots of flickering
  70.   setAllColor(CRGB::White);
  71.   show_at_max_brightness_for_power();
  72.   delay_at_max_brightness_for_power(3000);
  73.  
  74.   debugBlink(CRGB::Purple);    // flash a color so I can tell which is which
  75.   // this is flickering purple
  76.   FastLED.showColor(CRGB::White);
  77.   FastLED.delay(3000);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment