I have a complex sketch running on a Mega 2560.
The setup() function has mainly Serial.begins, Serial.prints and a few pinModes and digitalWrites to set pins HIGH for the OUTPUT pins.
If I put the pinModes and digitalWrites at he end of setup(). they don't work. On a DMM, they float at about 0.15-V.
If I move them to immediately after the Serial.begins, they work with solid 0.00-V and 5.10-V for LOW and HIGH respectively.
I can't see anything in the setup() script that might affect pin states.
My question is, is there an optimum place in setup() to configure pins or is my assumption that they can go anywhere in setup() wrong?
I haven't come across this problem before.