NeoPixel-KnightRider
NeoPixel-KnightRider copied to clipboard
Set speed, cycles, and width as variables
Forgive me, I am new to github, I don't know how to propose a change. However, this is from the top part of the code, I modified it for the speed, cycles, and width to be easily modified.
// SETUP YOUR OUTPUT PIN AND NUMBER OF PIXELS
#define PIN 6
#define NUM_PIXELS 105
#define SPEED 0 //lower speed = faster
#define CYCLES 2
#define WIDTH 6 //trail width
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
clearStrip(); // Initialize all pixels to 'off'
delay(100);
}
void loop() {
knightRider(CYCLES, SPEED, WIDTH, 0xFF1000); // Cycles, Speed, Width, RGB Color (original orange-red)
knightRider(CYCLES, SPEED, WIDTH, 0xFF00FF); // Cycles, Speed, Width, RGB Color (purple)
knightRider(CYCLES, SPEED, WIDTH, 0x0000FF); // Cycles, Speed, Width, RGB Color (blue)
knightRider(CYCLES, SPEED, WIDTH, 0xFF0000); // Cycles, Speed, Width, RGB Color (red)
knightRider(CYCLES, SPEED, WIDTH, 0x00FF00); // Cycles, Speed, Width, RGB Color (green)
knightRider(CYCLES, SPEED, WIDTH, 0xFFFF00); // Cycles, Speed, Width, RGB Color (yellow)
knightRider(CYCLES, SPEED, WIDTH, 0x00FFFF); // Cycles, Speed, Width, RGB Color (cyan)
knightRider(CYCLES, SPEED, WIDTH, 0xFFFFFF); // Cycles, Speed, Width, RGB Color (white)
clearStrip();
delay(2000);
// Iterate through a whole rainbow of colors
for(byte j=0; j<252; j+=7) {
knightRider(CYCLES, SPEED, WIDTH, colorWheel(j)); // Cycles, Speed, Width, RGB Color
}
clearStrip();
delay(2000);
}
This is a great suggestion, thanks! I'll leave this issue open until I can address this change.