Code: Select all
/*
04APR22 Arduno IDE 1.8.19 Compiled for Leonardo
Sketch uses 8996 bytes (31%) of program storage space. Maximum is 28672 bytes.
Global variables use 348 bytes (13%) of dynamic memory, leaving 2212 bytes for local variables. Maximum is 2560 bytes.
03APR22 Arduno IDE 1.8.5 Compiled for Leonardo
Sketch uses 8872 bytes (30%) of program storage space. Maximum is 28672 bytes.
Global variables use 348 bytes (13%) of dynamic memory, leaving 2212 bytes for local variables. Maximum is 2560 bytes.
*/
#include <Adafruit_NeoPixel.h>
// From LeftCoast https://github.com/leftCoast/LC_baseTools
#include <colorObj.h>
#include <mapper.h>
#include <multiMap.h>
#include <timeObj.h>
// From LeftCoast https://github.com/leftCoast/LC_neoPixel
#include <neoPixel.h>
#define STRING_PIN 6
#define NUM_PIXELS 60
#define MS_PER_MOVE 50
#define PIXELS_PER_COLOR 5
neoPixel theString(NUM_PIXELS, STRING_PIN);
timeObj moveDelay(MS_PER_MOVE);
int colorCount;
colorObj currentColor;
enum colorChoices { colorRd, colorWt, colorBl };
colorChoices colorChoice;
void setup() {
theString.setBrightness(63);// Global Brightness (0-256) attached to string name;
theString.begin();
theString.show();
moveDelay.start();
colorCount = 0;
colorChoice = colorRd;
currentColor.setColor(&red);
}
void setupNextMove(void) {
colorObj tempColor;
for (int i = NUM_PIXELS - 1; i >= 1; i--) {
tempColor = theString.getPixelColor(i - 1);
theString.setPixelColor(i, &tempColor);
}
if (colorCount >= PIXELS_PER_COLOR) {
switch (colorChoice) {
case colorRd :
colorChoice = colorWt;
currentColor.setColor(&white);
break;
case colorWt :
colorChoice = colorBl;
currentColor.setColor(&blue);
break;
case colorBl :
colorChoice = colorRd;
currentColor.setColor(&red);
break;
}
colorCount = 0;
}
//currentColor.blend(&black,50); // <<-- Try this for a cool effect.
theString.setPixelColor(0, ¤tColor);
colorCount++;
}
void loop() {
if (moveDelay.ding()) {
moveDelay.stepTime();
theString.show();
setupNextMove();
}
}