[SOLVED] pinMode(13,OUTPUT) at boot toggles HIGH

Hi all,

I need to set a pin (the pin 13 in this case) as output, and this pin MUST stay low until I change its state. Unfortunately, after a reset or just switching power on, the pin goes high for a short time. I need that the output pin stay low until my command. How can I avoid this? The output pin controls a global thermonuclear bomb and this behavior can be embarrassing :)

Thanks!

Luke

void setup() {
pinMode (13,OUTPUT);

}

void loop() {
  // how can I avoid that the output pin goes high at boot?
  
}

Does this make a difference...

void setup() {
pinMode (13,INPUT);
pinMode (13,OUTPUT);

}

void loop() {
  // how can I avoid that the output pin goes high at boot?
  
}

Does the problem only happen with pin 13 ? Perhaps the LED and associated circuitry is having an effect.

Well the bootloader uses pin 13 after a reset or power up until it times out and jumps to the prior loaded sketch. So possible fixes include:

Use a pin other then pin 13 Use a ICSP hardware programmer (can be another arduino board running arduinoISP) and load the sketch via file/upload using programmer. That will eliminate the bootloader altogether, so pin 13 won't be used other then as programmed by your sketch code.

In either case it's probably a good idea to wire an external pull-down resistor on pin 13, a small price to prevent global nucular war.

SOLVED!

Retrolefty has the right answer: the pin13 has a different behaviour, all works if using pin 10, even without the INPUT definition before OUTPUT.

Thanks to all!

Luke