johnwasser:
const byte ledPins[] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 45, };
unsigned long fadePeriods[13] = {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, }; //period between brightness changes on each LED
const byte NUMBER_OF_LEDS = sizeof(ledPins) / sizeof(ledPins[0]);
The code is not wrong but slightly safer to do it this way:const byte ledPins[] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 45, };
const byte NUMBER_OF_LEDS = sizeof(ledPins) / sizeof(ledPins[0]);
// period between brightness changes on each LED
unsigned long fadePeriods[NUMBER_OF_LEDS] = {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, };
By not only defining but USING the value NUMBER_OF_LEDS you will get a compiler warning if you add (or remove) LED pins without making a matching change in the number of values in fadePeriods[]. Another good way to do it:const byte NUMBER_OF_LEDS = 13;
const byte ledPins[NUMBER_OF_LEDS] = {13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 45, };
// period between brightness changes on each LED
unsigned long fadePeriods[NUMBER_OF_LEDS] = {15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, };
Thank you!
Really helping me a lot!