Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* three_sin demo
- By: Andrew Tuline
- Date: Oct, 2014
- 3 sine waves, one for each colour. I'm already doing a lot with 2 sine waves, so I didn't take this far.
- FastLED 2.1 is available at https://github.com/FastLED/FastLED/tree/FastLED2.1
- Note: If you receive compile errors (as I have in the Stino add-on for Sublime Text), set the compiler to 'Full Compilation'.
- */
- #include "FastLED.h" // FastLED library. Preferably the latest copy of FastLED 2.1.
- // Fixed definitions cannot change on the fly.
- #define LED_DT 13 // Serial data pin for WS2812B or WS2801
- #define COLOR_ORDER GRB // Are they RGB, GRB or what??
- #define LED_TYPE WS2812B // What kind of strip are you using?
- #define NUM_LEDS 24 // Number of LED's
- // Initialize changeable global variables.
- uint8_t max_bright = 255; // Overall brightness definition. It can be changed on the fly.
- struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
- // Initialize global variables for sequences
- uint8_t thisdelay = 8; // A delay value for the sequence(s)
- int wave1=0;
- int wave2=0;
- int wave3=0;
- uint8_t inc1 = 1;
- uint8_t inc2 = 1;
- uint8_t inc3 = -3;
- uint8_t lvl1 = 80;
- uint8_t lvl2 = 80;
- uint8_t lvl3 = 80;
- uint8_t mul1 = 20;
- uint8_t mul2 = 25;
- uint8_t mul3 = 22;
- void setup() {
- Serial.begin(57600);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.setBrightness(max_bright);
- set_max_power_in_volts_and_milliamps(5, 500); // FastLED 2.1 Power management set at 5V, 500mA
- random16_set_seed(4832); // Awesome randomizer (which we don't yet need here.)
- random16_add_entropy(analogRead(2));
- } // setup()
- void loop () {
- three_sin(); // Improved method of using non-blocking delay
- show_at_max_brightness_for_power(); // Power managed display of LED's
- delay_at_max_brightness_for_power(thisdelay*2.5);
- LEDS.countFPS();
- } // loop()
- void three_sin() {
- wave1 += inc1;
- wave2 += inc2;
- wave3 += inc3;
- for (int k=0; k<NUM_LEDS; k++) {
- leds[k].r = qsub8(quadwave8(mul1*k + wave1), lvl1); // Another fixed frequency, variable phase sine wave with lowered level
- // leds[k].g = qsub8(quadwave8(mul2*k + wave2), lvl2); // A fixed frequency, variable phase sine wave with lowered level
- //leds[k].b = qsub8(quadwave8(mul3*k + wave3), lvl3); // A fixed frequency, variable phase sine wave with lowered level
- }
- } // three_sin()
Advertisement
Add Comment
Please, Sign In to add comment