Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Rainbow March
- By: Andrew Tuline
- Date: Oct, 2014
- Rainbow marching up the strand. Pretty basic, but oh so popular.
- In this sketch, I vary the max_bright value to determine the point at which LED's start blinking
- when using set_max_power_in_volts_and_milliamps() and show_at_max_brightness_for_power()
- I'm using an Arduino powered by USB and a couple of 16850 batteries. A strand of 15 WS2812B LED's is powered by the Arduino 5V output.
- The accompanying video is at http://youtu.be/JwO5ZyhWWHw
- Table contains max_bright values at which point the LED's start blinking.
- Defined
- # LEDS ----------------Defined mA------------------------
- 100 200 500 1000 2000
- 25 58 125 n/a n/a n/a
- 50 27 55 148 n/a n/a
- 100 9 28 76 145 n/a
- 150 8 19 49 100 199
- 200 - 14 37 80 155
- FastLED is available at https://github.com/FastLED/FastLED
- */
- #include <FastLED.h> // FastLED library
- #define LED_DT 13 // Data pin
- #define NUM_LEDS 50 // Number of LED's
- #define COLOR_ORDER GRB // Change the order as necessary
- #define LED_TYPE WS2811 // What kind of strip are you using?
- uint8_t max_bright = 255; // How bright do we want to go
- struct CRGB leds[NUM_LEDS]; // Initialize our array
- // Initialize global variables for sequences
- uint8_t thisdelay = 8; // A delay value for the sequence(s)
- uint8_t thishue = 0; // Starting hue value.
- uint8_t thisdelta = 1; // Delta hue change between pixels
- int8_t thisrot = 1; // Hue rotation speed.
- uint8_t thisdir = 0; // Hue rotation direction.
- void setup() {
- Serial.begin(57600);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(max_bright); // FastLED brightness limiter
- set_max_power_in_volts_and_milliamps(5, 200); // FastLED 2.1 Power management set at 5V, 500mA
- } // setup()
- void loop () {
- rainbow_march();
- show_at_max_brightness_for_power();
- delay_at_max_brightness_for_power(thisdelay*2.5);
- uint8_t potval = map(analogRead(A4), 0, 1023, 0, 255);
- Serial.println(potval);
- FastLED.setBrightness(potval); // FastLED brightness limiter
- } // loop()
- void rainbow_march() { // The fill_rainbow call doesn't support brightness levels
- if(thisdir == 0) thishue += thisrot; else thishue -= thisrot;
- fill_rainbow( leds, NUM_LEDS, thishue, thisdelta );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement