Onderstaande heb ik op goed geluk in elkaar geflanst en probeer ik uit te breiden naar een 50 LED strip met 4 CylonBounces.
Maar ik bemerk dat nu ik er twee heb, de tweede (tussen LED 10 en 20) een beduidend minder helder licht geeft.
Iemand enig idee hoe dat kan komen?
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LEDS 20
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
// *** REPLACE FROM HERE ***
void loop() {
CylonBounce(0xff, 0, 0, 1, 50, 50);
}
void CylonBounce(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){
//for(int i = 0; i < NUM_LEDS-EyeSize-2; i++) {
for(int i = 0; i < 10-EyeSize-2; i++) {
setAll(0,0,0);
setPixel(i, red/10, green/10, blue/10);
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue);
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10);
setPixel(10+i, red/10, green/10, blue/10);
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue);
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10);
strip.show();
delay(SpeedDelay);
}
delay(ReturnDelay);
//for(int i = NUM_LEDS-EyeSize-2; i > 0; i--) {
for(int i = 10-EyeSize-2; i > 0; i--) {
setAll(0,0,0);
setPixel(i, red/10, green/10, blue/10);
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue);
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10);
setPixel(10+i, red/10, green/10, blue/10);
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue);
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10);
strip.show();
delay(SpeedDelay);
}
delay(ReturnDelay);
}
// *** REPLACE TO HERE ***
void setPixel(int Pixel, byte red, byte green, byte blue)
{
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
strip.show();
}