Arduino pin configurations

Hi everyone,i was wondering is there a way to tell if on start up boot(when the arduino/micro controller turns on for the first time) if a pin will flash or turn on briefly based on the data sheet? For example if a pin that has mosi/i2c or serial interfaces on that pin in the data sheet,when it starts up if i want to use that pin for a output thanks for your answer in advance im just trying to save time when planning pin outs on designs in the future

On the datasheet not that i've seen. Trial and error i've seen a post somewhere from someone who did but don't have the bookmark

1 Like

On reset the I/O pins will be in high Z input mode. Control registers have to be set to enable other functions. You would have to look at the bootloader code to see what state it leaves things in.

1 Like

Certainly not the datasheet. On power-up or reset, all of the pins are set to INPUT. They are not driving any significant current into external devices. They are not drawing any significant current from outside devices.

The things that can cause pins to "flash or turn on briefly" would be external devices (like the USB-to-Serial chip connected to Pin 0 and Pin 1 or the circuit for the built-in LED connected to Pin 13) or firmware (the bootloader reading Serial and possibly blinking the built-in LED) or software (the Arduino run-time library or your sketch).

I think that pins other than Serial and LED_BUILTIN should be safe from firmware interference.

For your OUTPUT pins, remember that you can do a digitalWrite() before pinMode(OUTPUT) to keep from driving the output to an undesired level. Before you set pinMode(OUTPUT) you can use pull-up or pull-down resistors to keep your outputs (initially inputs) from floating to an undesired level.

2 Likes

The datasheet states all output pins are "open", neither high or low.

But, you could hack the bootloader. Or, easier, just include your requirement in setup() and stall using delay() moving on to loop() until you have configured the output pin, done whatever, and done any cleanup necessary before moving into loop().

1 Like

You mean digital writing everything low then writing them high in the code?

No. You have no control over the pins until your setup() code starts. You should use pull-up or pull-down resistors to force the OUTPUT pins to the desired initial state before you set pinMode(pin, OUTPUT). Then, in setup(), use digitalWrite() to set the OUTPUT pin to the (same) desired initial state before you set pinMode(pin, OUTPUT).

1 Like