Skip to content

Instantly share code, notes, and snippets.

@Jivemofo
Last active April 17, 2016 21:57
Show Gist options
  • Save Jivemofo/42773d7ea95dc8adfecf074b4fd2dbad to your computer and use it in GitHub Desktop.
Save Jivemofo/42773d7ea95dc8adfecf074b4fd2dbad to your computer and use it in GitHub Desktop.
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 16
#define DATA_PIN 3
CRGB leds[NUM_LEDS];
int
currentColor = 0,
lastColor = 0,
currentSaturation = 0,
lastSaturation = 0,
currentBrightness = 50,
lastBrightness = 0,
ledPosition = 0,
lastPosition = 0,
offPosition = 0;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
//start with Blue as Starting LED at position 2
//set LEDs to their positions and increment
for (int i = 0; i<NUM_LEDS; i++){
leds[i] = offPosition;
leds[i+1] = lastPosition;
leds[i+2] = ledPosition;
updateWheel(); //call update wheel function
currentColor++; //advance color each pass through the loop
if(currentColor==255){currentColor=0;}
}
}
void updateWheel() {
leds[offPosition] = CHSV(0,0,0);
leds[lastPosition] = CHSV(currentColor,currentSaturation,currentBrightness%50);
leds[ledPosition] = CHSV(currentColor,currentSaturation,currentBrightness);
FastLED.show();
offPosition = lastPosition;
lastPosition = ledPosition;
ledPosition = (ledPosition + 1) % 256;
}
@Jivemofo
Copy link
Author

there are errors but i'm not sure where to start with this.

@Jivemofo
Copy link
Author

not really sure about the relationship between the wheel update function and the for loop. i guess you would eventually code a millis() check in the main loop for the wheelUpdate? i was hoping to figure out how to advance the dot around the ring while cycling through the hue/color range, but do i need to organize it as a mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment