Skip to content

Instantly share code, notes, and snippets.

@todbot
Created January 22, 2017 03:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save todbot/eafe8467099bdb641a744b539af915d2 to your computer and use it in GitHub Desktop.
Save todbot/eafe8467099bdb641a744b539af915d2 to your computer and use it in GitHub Desktop.
#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