Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h" // FastLED library.
- #if FASTLED_VERSION < 3001000
- #error "Requires FastLED 3.1 or later; check github for latest code."
- #endif
- // Fixed definitions cannot change on the fly.
- #define LED_DT 2 // Serial data pin
- #define LED_CK // Clock pin for WS2801 or APA102
- #define COLOR_ORDER BGR // It's GRB for WS2812B and GBR for APA102
- #define LED_TYPE WS2812B // What kind of strip are you using (APA102, WS2801 or WS2812B)?
- #define NUM_LEDS 120 // Number of LED's
- #define BRIGHTNESS 200
- // Initialize changeable global variables. // Overall brightness definition. It can be changed on the fly.
- struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
- void setup() {
- Serial.begin(115200);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // For WS2812B
- FastLED.setBrightness(BRIGHTNESS);
- set_max_power_in_volts_and_milliamps(5, 1000); // FastLED 2.1 Power management set at 5V, 500mA
- } // setup()
- void loop () {
- rainbow_march(200, 10);
- FastLED.show();
- } // loop()
- void rainbow_march(uint8_t thisdelay, uint8_t deltahue) { // The fill_rainbow call doesn't support brightness levels.
- 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.
- // thishue = beat8(50); // This uses a FastLED sawtooth generator. Again, the '50' should not change on the fly.
- // thishue = beatsin8(50,0,255); // This can change speeds on the fly. You can also add these to each other.
- fill_rainbow(leds, NUM_LEDS, thishue, deltahue); // Use FastLED's fill_rainbow routine.
- } // rainbow_march()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement