Created
April 15, 2016 06:16
-
-
Save gatana/7db9f92a468cae4de4f4fba3df641cd3 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" | |
// How many leds in your strip? | |
#define NUM_LEDS 15 | |
// For led chips like Neopixels, which have a data line, ground, and power, you just | |
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, | |
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN | |
#define DATA_PIN 5 | |
#define CLOCK_PIN 6 | |
// Define the array of leds | |
CRGB leds[NUM_LEDS]; | |
unsigned long bounces; | |
unsigned int timeDelay = 300; | |
void setup() { | |
Serial.begin(57600); | |
Serial.println("resetting"); | |
// Change depending on the LED strip model | |
LEDS.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); | |
LEDS.setBrightness(84); | |
} | |
void loop() { | |
static uint8_t hue = 0; | |
Serial.print("x"); | |
// every 4 bounces or 2 loops | |
if (bounces%2 == 0) { | |
// now supports 4.25 colors! | |
hue = hue + 60; | |
} | |
// First slide the led in one direction | |
for(int i = 0; i < NUM_LEDS; i++) { | |
// if it passes half way | |
if (i+4 == NUM_LEDS/2) { | |
// now supports 4.25 colors! | |
hue = hue + 60; | |
} | |
leds[i] = CHSV(hue, 255, (255/5)*1); | |
leds[i+1] = CHSV(hue, 255, (255/5)*2); | |
leds[i+2] = CHSV(hue, 255, (255/5)*3); | |
leds[i+3] = CHSV(hue, 255, (255/5)*4); | |
leds[i+4] = CHSV(hue, 255, 255); | |
hue++; | |
// Show the leds | |
FastLED.show(); | |
// go Back to Black | |
leds[i] = CRGB::Black; | |
delay(timeDelay); | |
} | |
// // then slide the LED into the other direction | |
for(int i = (NUM_LEDS)-1; i >= 0; i--) { | |
// // if it passes half way | |
// if (i == NUM_LEDS/2) { | |
// // now supports 4.25 colors! | |
// hue = hue + 60; | |
// } | |
leds[i] = CHSV(hue, 255, 255); | |
leds[i+1] = CHSV(hue, 255, (255/5)*4); | |
leds[i+2] = CHSV(hue, 255, (255/5)*3); | |
leds[i+3] = CHSV(hue, 255, (255/5)*2); | |
leds[i+4] = CHSV(hue, 255, (255/5)*1); | |
hue++; | |
// Show the leds | |
FastLED.show(); | |
// go Back to Black | |
leds[i+4] = CRGB::Black; | |
delay(timeDelay); | |
} | |
// count as a bounce | |
bounces ++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment