Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #include "FastLED.h" // FastLED library.
  2.  
  3. #if FASTLED_VERSION < 3001000
  4. #error "Requires FastLED 3.1 or later; check github for latest code."
  5. #endif
  6.  
  7. // Fixed definitions cannot change on the fly.
  8. #define LED_DT 2 // Serial data pin
  9. #define LED_CK // Clock pin for WS2801 or APA102
  10. #define COLOR_ORDER BGR // It's GRB for WS2812B and GBR for APA102
  11. #define LED_TYPE WS2812B // What kind of strip are you using (APA102, WS2801 or WS2812B)?
  12. #define NUM_LEDS 120 // Number of LED's
  13. #define BRIGHTNESS 200
  14.  
  15. // Initialize changeable global variables. // Overall brightness definition. It can be changed on the fly.
  16.  
  17. struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
  18.  
  19.  
  20.  
  21. void setup() {
  22.  
  23. Serial.begin(115200);
  24.  
  25. LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // For WS2812B
  26.  
  27.  
  28. FastLED.setBrightness(BRIGHTNESS);
  29. set_max_power_in_volts_and_milliamps(5, 1000); // FastLED 2.1 Power management set at 5V, 500mA
  30.  
  31. } // setup()
  32.  
  33.  
  34.  
  35. void loop () {
  36.  
  37. rainbow_march(200, 10);
  38. FastLED.show();
  39.  
  40. } // loop()
  41.  
  42.  
  43.  
  44. void rainbow_march(uint8_t thisdelay, uint8_t deltahue) { // The fill_rainbow call doesn't support brightness levels.
  45.  
  46. uint8_t thishue = millis()*(255-thisdelay)/255; // To change the rate, add a beat or something to the result. 'thisdelay' must be a fixed value.
  47.  
  48. // thishue = beat8(50); // This uses a FastLED sawtooth generator. Again, the '50' should not change on the fly.
  49. // thishue = beatsin8(50,0,255); // This can change speeds on the fly. You can also add these to each other.
  50.  
  51. fill_rainbow(leds, NUM_LEDS, thishue, deltahue); // Use FastLED's fill_rainbow routine.
  52.  
  53. } // rainbow_march()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement