Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Random block of 4 leds, very fast.
- /* Kelvin Mead Aug/14
- #include <FastSPI_LED2.h>
- #define NUM_LEDS 320
- CRGB leds[NUM_LEDS];
- long previousMillis = 0; // will store last time LED was updated
- long interval = 100; // interval at which to blink (milliseconds)
- int bright = 255; // easy adjustable brightness
- void setup() {
- delay(2000);
- LEDS.setBrightness(bright);
- LEDS.addLeds<WS2811, 13>(leds, NUM_LEDS);
- }
- void loop() {
- unsigned long currentMillis = millis();
- if(currentMillis - previousMillis > interval) {
- previousMillis = currentMillis;
- //put programs in here to be controlled by the delay time
- // program name (r, g, b, speed)
- random4(51, 102, 153, 50);
- LEDS.setBrightness(bright);
- } // end timed loop
- } // end void loop
- void random4(int cred, int cblu, int cgrn, int cinterval) {
- interval = cinterval;
- // clear all
- memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
- int random4 = random(NUM_LEDS);
- leds[random4].setRGB(cred, cblu, cgrn);
- leds[random4-1].setRGB(cred, cblu, cgrn);
- leds[random4-2].setRGB(cred, cblu, cgrn);
- leds[random4-3].setRGB(cred, cblu, cgrn);
- LEDS.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement