Created
January 22, 2017 03:02
-
-
Save todbot/eafe8467099bdb641a744b539af915d2 to your computer and use it in GitHub Desktop.
This file contains 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 LEDPIN D4 | |
#define NUM_LEDS 5 | |
CRGB leds[NUM_LEDS]; | |
CRGB leds_virt[NUM_LEDS]; | |
const int led_map[NUM_LEDS] = { | |
2, 3, 0, 1, 4 | |
}; | |
uint8_t gHue; | |
// turn virtual LEDs into real LEDs | |
void led_swizzle() { | |
for( int i=0; i<NUM_LEDS; i++) { | |
leds[i] = leds_virt[led_map[i]]; | |
} | |
} | |
void setup() { | |
FastLED.addLeds<WS2812, LEDPIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); | |
} | |
void loop() { | |
fill_rainbow( leds_virt, NUM_LEDS, gHue++, 10); | |
led_swizzle(); | |
FastLED.show(); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment