Guest User

Untitled

a guest
Feb 22nd, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define LED_PIN 5
  4. #define NUM_LEDS 300
  5. #define BRIGHTNESS 64
  6. #define LED_TYPE WS2811
  7. #define COLOR_ORDER RGB
  8. CRGB leds[NUM_LEDS];
  9.  
  10. #define UPDATES_PER_SECOND 100
  11.  
  12. // This example shows several ways to set up and use 'palettes' of colors
  13. // with FastLED.
  14. //
  15. // These compact palettes provide an easy way to re-colorize your
  16. // animation on the fly, quickly, easily, and with low overhead.
  17. //
  18. // USING palettes is MUCH simpler in practice than in theory, so first just
  19. // run this sketch, and watch the pretty lights as you then read through
  20. // the code. Although this sketch has eight (or more) different color schemes,
  21. // the entire sketch compiles down to about 6.5K on AVR.
  22. //
  23. // FastLED provides a few pre-configured color palettes, and makes it
  24. // extremely easy to make up your own color schemes with palettes.
  25. //
  26. // Some notes on the more abstract 'theory and practice' of
  27. // FastLED compact palettes are at the bottom of this file.
  28.  
  29. int x = 0;
  30. // Get x value from Shuffleboard.
  31. int y = 1;
  32.  
  33. CRGBPalette16 currentPalette;
  34. TBlendType currentBlending;
  35.  
  36. extern CRGBPalette16 myRedWhiteBluePalette;
  37. extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
  38.  
  39.  
  40. void setup() {
  41. delay( 3000 ); // power-up safety delay
  42. FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  43. FastLED.setBrightness( BRIGHTNESS );
  44.  
  45. currentPalette = RainbowColors_p;
  46. currentBlending = LINEARBLEND;
  47. }
  48.  
  49. void loop()
  50. {
  51. static uint8_t startIndex = 0;
  52. startIndex = startIndex + 1; /* motion speed */
  53. if (x == 0) {
  54. y = 0;
  55. for( int i = 0; y = 1; i++) {
  56. leds[i] = CRGB::Red;
  57. FastLED.show();
  58. if (x != 0) {
  59. int y = 1;
  60. }
  61. }
  62. }
  63. else if (x == 1) {
  64. y = 0;
  65. for( int i = 0; y = 1; i++) {
  66. leds[i] = CRGB::Blue;
  67. FastLED.show();
  68. if (x != 1) {
  69. int y = 1;
  70. }
  71. }
  72. }
  73. /*Was rainbow palette but doesn't work,
  74. FillLEDS to UPDATES_PER_SECONDS) };
  75. needs to be in a void loop(), but
  76. a void loop() can't be in another
  77. void loop, which we already have.
  78. So this code only runs red and blue.
  79. while (x == 2) {
  80. FillLEDsFromPaletteColors( startIndex);
  81. FastLED.show();
  82. FastLED.delay(1000 / UPDATES_PER_SECOND);
  83. }*/
  84. }
  85. void FillLEDsFromPaletteColors( uint8_t colorIndex)
  86. {
  87. uint8_t brightness = 255;
  88.  
  89. }
  90.  
  91. void ChangePalettePeriodically()
  92. {
  93. uint8_t secondHand = (millis() / 1000) % 60;
  94. static uint8_t lastSecond = 99;
  95.  
  96. }
  97.  
  98. const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
  99. {
  100. CRGB::Red,
  101. CRGB::Gray, // 'white' is too bright compared to red and blue
  102. CRGB::Blue,
  103. CRGB::Black,
  104.  
  105. CRGB::Red,
  106. CRGB::Gray,
  107. CRGB::Blue,
  108. CRGB::Black,
  109.  
  110. CRGB::Red,
  111. CRGB::Red,
  112. CRGB::Gray,
  113. CRGB::Gray,
  114. CRGB::Blue,
  115. CRGB::Blue,
  116. CRGB::Black,
  117. CRGB::Black
  118. };
Add Comment
Please, Sign In to add comment