// ************************************************************************************************
//
// Documentation for this, and the rest of the LC libraries that make this up.
// Here's the book : https://github.com/leftCoast/LC_libraryDocs/blob/main/LC_libraries.pdf
// Search for : LC_baseTools, LC_neoPixel
//
// That should keep you busy.
//
// ************************************************************************************************
#include <neoPixel.h>
#include <mechButton.h>
#include <timeObj.h>
#define NUM_LEDS 7
#define MS_PER_LED 1000
#define COLOR red
neoPixel theLEDs(NUM_LEDS,3);
mechButton ourBtn(2);
timeObj LEDTimer(MS_PER_LED);
int index;
bool running;
void setup() {
theLEDs.begin();
theLEDs.setAll(&black);
theLEDs.show();
ourBtn.setCallback(btnClick);
index = 0;
running = false;
}
void btnClick(void) {
if (!ourBtn.getState()) {
if (running) {
theLEDs.setAll(&black);
theLEDs.show();
running = false;
} else {
index = 0;
theLEDs.setPixelColor(index++,&COLOR);
theLEDs.show();
LEDTimer.start();
running = true;
}
}
}
void loop() {
idle();
if (running) {
if (LEDTimer.ding()) {
if (index<NUM_LEDS) {
LEDTimer.stepTime();
theLEDs.setPixelColor(index++,&COLOR);
theLEDs.show();
}
}
}
}