Need help writing more efficient code (total newbie)

This is the standard way to arrive at the number of elements in an array

#define ARRAY_SIZEOF(ARRAY) (sizeof(pinsLED) / sizeof(pinsLED[0]))

sizeof(pinsLED) => size of the array in bytes,
sizeof(pinsLED[0])) => size of the first element in bytes

(sizeof(pinsLED) / sizeof(pinsLED[0])) => size of the array in bytes / size of the first element in bytes => number of elements in the array

The parameter (ARRAY) in this case serves no purpose that I can see.

Personally I would use a name like N_PINS

#define N_PINS (sizeof(pinsLED) / sizeof(pinsLED[0]))

Because the word sizeof has special meaning and if your elements were ints or longs the constant ARRAY_SIZEOF would IMO give the wrong impression about exactly what it refers to.


Rob