The above example is a good one for learning how to use arrays. You might not want to go for the extra challenge, but I'd use an array of class objects.
Pulser(int pin, long wait = 10)
p = pin;
w = wait;
l = -1;
l = millis();
if (l >= 0 && millis() >= l + w)
l = -1;
This is a class I have called Pulser. You can make many "objects" which are independent of each other, but have the same functions available for them. In this case, it needs a mandatory pin number, and can optionally take an auto-off wait parameter, 10 milliseconds if not given.
#define countof(a) (sizeof(a)/sizeof(*(a)))
Pulser outs =
Pulser(2), // support pin 2
Pulser(5), // support pin 5
Pulser(7, 100), // pin 7 auto-offs after a longer pulse
Then you just need to use them.
// decide if any outs need to be pulsed HIGH
// update all pulse auto-off status
for (i = 0; i < countof(outs); i++)