Hello all,
I began a Project that i cant keep my hands away from. The connected PIR motion sensors, one at the top of the stairs and one at the bottom are hooked up to an Elegoo Mega(The "Good" Arduino Mega knock-off), connected to about 680 WS2812B LED Lights spread out on 15 Stairs that have different amount of LED's(Different amount because some stairs are bigger, others the same). The Idea is that when someone walks up or down the stairs, the lights fade in(fading out probably works on the same principal)
Here is my Code:
void fadeInAllStairsTop(){
int StairArray [15] = {40,40,40,40,40,40,40,40,42,45,53,51,42,40,40};
const int wait = 10;
for(uint16_t k = 0; k < 15; k++){
for(uint16_t j = 0; j < 235; j++){
int startinc, endinc, current;
current = StairArray[k];
startinc += StairArray[k];
endinc += StairArray[k];
for (uint16_t i = startinc-current; i < endinc; i++){
strip.setPixelColor(i ,j ,j ,j);
}
strip.show();
delay(wait);
}
}
}
Sadly the array created in the beginning doesnt seem to work as i had expected(none of them turn on), i have some experience in coding but not in c++, my best guess is that the stairs aren't incrementing as I expected( Stair 1: 0-40 LEDS, then Stair 2: 40-80 LEDs etc.) hopefully someone can point out where my obvious mistake resides.