#include <FastLED.h>
///////////////////////////////////////////////////////////////////////////////////////////
//
// Move a white dot along the strip of leds. This program simply shows how to configure the leds,
// and then how to turn a single pixel white and then off, moving down the line of pixels.
//
// How many leds are in the strip?
#define NUM_LEDS 5
#define DATA_PIN 2
// This is an array of leds. One item for each led in your strip.
CRGB leds[NUM_LEDS];
// This function sets up the leds and tells the controller about them
void setup() {
delay(200);
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is typical
}
void loop() {
// Moving a single led:
for(int theLed = 0; theLed < NUM_LEDS; theLed = theLed + 1) {
leds[theLed] = CRGB::Red;
FastLED.show(); //Show the leds
delay(500); //Small delay to slow things down
leds[theLed] = CRGB::Black; // Turn current led back to black
}
//Set all to same colour:
delay(500);
for(int theLed = 0; theLed < NUM_LEDS; theLed = theLed + 1) {
leds[theLed] = CRGB::Red;
}
FastLED.show(); //Show the leds
delay(500); //Small delay to slow things down
}
void illuminateAll(col, pause) {
for(int theLed = 0; theLed < NUM_LEDS; theLed = theLed + 1) {
leds[theLed] = CRGB::Red;
}
FastLED.show();
}
void illuminateOne(col, pause) {
for(int theLed = 0; theLed < NUM_LEDS; theLed = theLed + 1) {
leds[theLed] = CRGB::Red;
FastLED.show(); //Show the leds
delay(500); //Small delay to slow things down
leds[theLed] = CRGB::Black; // Turn current led back to black
}
}