Skip to content

Instantly share code, notes, and snippets.

@vongomben
Created April 8, 2017 09:23
Show Gist options
  • Save vongomben/a15c62094f862c3c0e30fc5c66f19748 to your computer and use it in GitHub Desktop.
Save vongomben/a15c62094f862c3c0e30fc5c66f19748 to your computer and use it in GitHub Desktop.
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 8
// 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 3
// #define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
// Turn the LED on, then pause
for(int i = 0; i <= 7; i++){
leds[i] = CRGB::Red;
leds[i-1] = CRGB::Black;
leds[i+1] = CRGB::Black;
Serial.println(i);
FastLED.show();
delay(50);
}
for(int i = 7; i >= 0; i--){
leds[i] = CRGB::Red;
leds[i-1] = CRGB::Black;
leds[i+1] = CRGB::Black;
Serial.println(i);
FastLED.show();
delay(50);
}
// // Now turn the LED off, then pause
// leds[1] = CRGB::Green;
// FastLED.show();
// delay(500);
// // Now turn the LED off, then pause
// leds[1] = CRGB::Blue;
// FastLED.show();
// delay(500);
// leds[1] = CRGB::Black;
// FastLED.show();
// delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment