DUE default pin state on reset / power on

Hi All,

I am not sure if this question has been clearly answered for DUE, sorry if double posting ( I only found info pe MEGA or UNO ).

I am controlling some optocouplers ( 4N35 ) that are powered by a 2N3904 in order to not exceed the SAM3X chip current, something like this:

digitalPin -> resistor -> transistor 2n3904 -> optocoupler GND
+3.3 V -> resistor -> optocoupler +

Here is the setup code that take care of that part:

for (int count=0;count<24;count++) {
pinMode(cameras[count], OUTPUT);
digitalWrite(cameras[count], LOW);
}

There are 24 pins in that array.

There are a couple of question and behaviours that I am not sure are 100% normal.

  1. On power on, immediately after plugging the AC adaptor or USB the output go HIGH for a fraction of a seconds
  2. On serial connect all pins go HIGH for a fraction of a second ( I understand this is normal ? How can this be avoided ? )

Another thing, after powering on the board ( usb or ac, doesn't matter ) the pins go high for a short time, then go low about 2 seconds then go high and low very fast again. Something like this:

Power ON: HIGH <> LOW, wait 2 seconds then HIGH <> LOW

After this sequence the board starts to respond to serial and behave normally.

The boot sequence takes about 3.. 4 seconds ( with two HIGH <> LOW flaps ) is this normal ?

Also on some situations after only touching the metal of the USB plug to the metal of the USB connector on the board triggers a LOW <> HIGH flap.

Thanks !!!

Hi friend! Use pull-down resistor on arduino's outputs and it will be ok.

Yes, use pull down resistors. I've seen this same problem. I believe all of the digital pins are set as inputs upon start up. If you don't pull them down with something you stand a good chance of them floating up to some voltage that isn't zero. I've seen this happen with signal mosfets connected directly to digital pins. On start up the mosfets will trigger on for a fraction of a second (something like 100ms). This is not always a really great thing. You can prevent this with a weak pull down resistor (say, 10k or so). Still, set the pins as outputs as soon as you can in your sketch.

Thanks, I will try that !

What about the boot time ?