Go Down

Topic: Arduino triggers all pins at powerup (Read 2638 times) previous topic - next topic


Hello all colegues!

On my arduino mega I have 8 optocouplers and then transistors to drive electromagnetic valves. The problem is when I reset or power up the board all the pins get triggerd and all my valves get also triggered. I dont want that!

So I bypassed the problem with a main relay that in NC state cuts the supply of 12v for the valves so they do not get triggered at startup. And then later on the code after the first seconds connects the relay and lets the power to all the valves that can now be triggered via optocouplers/transistors.

Is there another way to bypass this  - with code - bootloader - a simple trick...



We would probably have to see the wiring schematic you are using showing how you are driving the valves, it's possible you require pull-down resistors on your digital outputs.



I believe (and I hope someone corrects me if I am wrong) that you could hook an electrolytic capacitor to ground at the point where your base current resistor connects to the transistor controlling the valve (that, or before the resistor - between it and the microcontroller pin).

Basically, the idea is that for a transient pulse signal from a pin from the microcontroller, the current would be driven to ground via the capacitor because it can't charge quick enough (you would need to add a resistor in series with the cap to control the rate, the size of the cap will play a role too - you can find online how to calculate what resistor, etc is needed for charge times); but a steady output would charge the capacitor and finally allow it to pass to the base of the transistor when fully charges (because at that point the capacitor looks like a large resistor to the current, when it is fully charged).

So transients won't affect it, but a steady output from the pin will turn it on.

I think.

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


The basic problem is that on power up all the pins are set to be inputs. Therefore they float. Depending on the circuit design this can look to the driver like a signal and thus look like the outputs are pulsed. So simply design your driver circuit not to switch on a floating output. As was mentioned before pull down resistors are a simple modification that normally work.


Thats the basic schematics. I have tested it with solenoids, motors and relais.

I did some experiments and the pulsation only happens when i plug in the arduino to usb or ext power suply.

Thanks for all the answers.



and the pulsation only happens when i plug in the arduino to usb or ext power suply.

Did you try pressing the reset button?


Yes, at the reset everything is OK, no triggering.


So it is not a problem with the arduino itself but your external drivers. You need to post a schematic of what you have in order for us to help you from here.


I have posted the schematics for one valve in the link in the post above.
Basically it does not matter what you have connected,  I can connect only one LED and it does not matter on which port. On the powerup it blinks.

I have 3 Arduinos Mega and it is the same on all of them.




For the LEDs and for the optocouplers I have used the same value of  resistors (330R).

I have tried to change the values of the resistor on the optocoupler (330R) to higher (1k or even 10K) and there was no more pulsating at power up. (if i tested with >=2 drivers) And I have distributed the gnd connections (before on single gnd pin) to other avaliable gnd pins. I think that the problem lies with the current that passes through the optocoupler to arduinos gnd. Too much?



I have noticed this, but only when connected via USB, can you confirm if this is happening for you only over USB, or for mains also?


Yes I am going to test everything again tomorrow in "the lab" and I will let you know. There is also difference in the way on how many GND pins you have distributed the circuit.


think that the problem lies with the current that passes through the optocoupler to arduinos gnd. Too much?

No that's wrong.


Hello dear colegues,

i spent my afternoon experimenting and researching the problem and i found something that similar:

Its a topic about reseting when driving a motor:

Go Up