Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define LED_PIN 9
- #define LED_TYPE WS2812B
- #define COLOR_ORDER GRB
- #define NUM_LEDS 48
- CRGB leds[NUM_LEDS];
- int location =0;
- unsigned long time;
- void setup() {
- FastLED.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds, NUM_LEDS);
- time=millis();
- }
- void loop()
- {
- if (millis()>=time) { // update leds every 10ms(=50hz)
- time=time+10;
- chase();
- }
- }
- void chase()
- {
- if (location==255) location=0;
- location=location+1;
- CHSV start_col = CHSV(location, 255, 255);
- CHSV end_col = CHSV(255+location, 255, 255);
- fill_gradient(leds,0,end_col,NUM_LEDS,start_col,BACKWARD_HUES);
- int brightest=location/255.0*NUM_LEDS;
- for (byte w=0;w<NUM_LEDS;w++) {
- leds[brightest].fadeLightBy(w*5.3);
- brightest=brightest-1;
- if (brightest<0) brightest=NUM_LEDS;
- }
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement