Is there a way to debug code in Setup? Trying to use a for

jremington:
Do you have a current limit resistor on each LED?

At 20 mA/LED, 40 LEDs on at once could exceed the total current limit of the Mega, and the Mega voltage regulator will probably overheat.

Arduino Playground - HomePage

Thanks.... I'm actually using a MOS FET boards which have a LED and limiting resister.
Sketch will not have more than 5 LEDs firing at one time.