Created
October 6, 2015 21:14
-
-
Save mock-turtle/e0f88ba7b555996af350 to your computer and use it in GitHub Desktop.
A fastLED based chaser w 4 colours bouncing btwn each other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FastLED.h> | |
#define NUM_LEDS 12 | |
#define PIN 6 | |
CRGB leds[NUM_LEDS]; | |
void setup() { | |
FastLED.addLeds<NEOPIXEL, PIN>(leds, NUM_LEDS); | |
} | |
void loop() { | |
//GREEN BAND | |
for(int greenband = 0; greenband < (NUM_LEDS-1)/4+1/4; greenband++) { | |
leds[greenband] = CRGB::Green; | |
leds[greenband-1] = CRGB::Green; | |
leds[greenband+1] = CRGB::Green; | |
//BLUE BAND | |
leds[NUM_LEDS-1-greenband] = CRGB::Blue; | |
leds[NUM_LEDS-greenband] = CRGB::Blue; | |
leds[NUM_LEDS-2-greenband] = CRGB::Blue; | |
//PINK BAND | |
leds[(NUM_LEDS-1)/2+1/2-greenband] = CRGB::Salmon; | |
leds[(NUM_LEDS-1)/2+3/2-greenband] = CRGB::Salmon; | |
leds[(NUM_LEDS-1)/2-1/2-greenband] = CRGB::Salmon; | |
//ORANGE BAND | |
leds[(NUM_LEDS-1)/2+1/2+greenband] = CRGB::Orange; | |
leds[(NUM_LEDS-1)/2+3/2+greenband] = CRGB::Orange; | |
leds[(NUM_LEDS-1)/2-1/2+greenband] = CRGB::Orange; | |
FastLED.show(); | |
delay(400); | |
leds[greenband-1] = CRGB::Black; | |
leds[NUM_LEDS-greenband] = CRGB::Black; | |
leds[(NUM_LEDS-1)/2+3/2-greenband] = CRGB::Black; | |
leds[(NUM_LEDS-1)/2-1/2+greenband] = CRGB::Black; | |
} | |
//COMING BACK | |
for(int greenband = (NUM_LEDS-1)/4+1/4; greenband >= 0; greenband--) { | |
leds[greenband] = CRGB::Green; | |
leds[greenband-1] = CRGB::Green; | |
leds[greenband+1] = CRGB::Green; | |
leds[NUM_LEDS-1-greenband] = CRGB::Blue; | |
leds[NUM_LEDS-greenband] = CRGB::Blue; | |
leds[NUM_LEDS-2-greenband] = CRGB::Blue; | |
leds[(NUM_LEDS-1)/2+1/2-greenband] = CRGB::Salmon; | |
leds[(NUM_LEDS-1)/2+3/2-greenband] = CRGB::Salmon; | |
leds[(NUM_LEDS-1)/2-1/2-greenband] = CRGB::Salmon; | |
leds[(NUM_LEDS-1)/2+1/2+greenband] = CRGB::Orange; | |
leds[(NUM_LEDS-1)/2+3/2+greenband] = CRGB::Orange; | |
leds[(NUM_LEDS-1)/2-1/2+greenband] = CRGB::Orange; | |
FastLED.show(); | |
delay(400); | |
leds[greenband+1] = CRGB::Black; | |
leds[NUM_LEDS-2-greenband] = CRGB::Black; | |
leds[(NUM_LEDS-1)/2-1/2-greenband] = CRGB::Black; | |
leds[(NUM_LEDS-1)/2+3/2+greenband] = CRGB::Black; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment