user639: The Arduino Mega 2560 Rev 3 has multiple relays connected to its digital output pins. 
Whenever the Arduino is reset (using reset button, turning on Serial Monitor etc), the Arduino turns on all relays then turns them off. I cant find any function in my sketch that causes the outputs to go HIGH then LOW. Assuming this is a normal feature of the Arduino, how can we prevent this and ensure that the outputs do not flip to the HIGH state?

user33186: Just to add my five cents. I also experienced a relay, driven by a bipolar npn lowside. turning on while timers, Serial etc init and then turn off again. 
Using INTERNAL_PULLUP mode helped me as well.
have no idea why. It must have something to do with relays beeing current driven. Mine requires 20 mA at 5V 

user368: The ATmega2560 itself comes out of reset with all pins in high-Z (DDRx=0, PORTx=0). Your observations are likely due to the bootloader. Check the bootloader source to verify that it is responsible for this.

user3877: The relay board you are using has active low inputs to control the relays.
In your sketch when you are initialising the pins as outputs they are by default set low (this is turning all your relays on).
set the pins as outputs and set them high, they will be low for a very short time (too short for the relay to turn on effectively).

639: <p>The Arduino Mega 2560 Rev 3 has multiple relays connected to its digital output pins. </p>

<p>Whenever the Arduino is reset (using reset button, turning on Serial Monitor etc), the Arduino turns on all relays then turns them off. I cant find any function in my sketch that causes the outputs to go HIGH then LOW. Assuming this is a normal feature of the Arduino, how can we prevent this and ensure that the outputs do not flip to the HIGH state?</p>
 33186: <p>Just to add my five cents. I also experienced a relay, driven by a bipolar npn lowside. turning on while timers, Serial etc init and then turn off again. 
Using INTERNAL_PULLUP mode helped me as well.</p>

<p>have no idea why. It must have something to do with relays beeing current driven. Mine requires 20 mA at 5V </p>
 368: <p>The ATmega2560 itself comes out of reset with all pins in high-Z (DDRx=0, PORTx=0). Your observations are likely due to the bootloader. Check the bootloader source to verify that it is responsible for this.</p>
 3877: <p>The relay board you are using has active low inputs to control the relays.
In your sketch when you are initialising the pins as outputs they are by default set low (this is turning all your relays on).
set the pins as outputs and set them high, they will be low for a very short time (too short for the relay to turn on effectively).</p>
