How to start arduino with pin hi (pull up resistor enabled)

Hey, I have 5V relays (with external pover, optos and logic), but they are driven to pull control pins to ground.

My problem is, that sometimes relays activate when I start arduino & relays, and I feel I did something wrong by code.

(I know all relays will close when I close arduino and thats ok.)

void setup() {
  pinMode(3, OUTPUT);    // sets the digital pin 13 as output
  digitalWrite(PINx, HIGH); //makes PINx high almost immediately (few uS)

I found one topic about that: [SOLVED] Arduino powers all pins at start-up

But is it really that I should extra pullup resistor on every pin?

these controls computers, lights and stuff. so I dont want extra releys activations when I start system, Idea is to have smooth power on, one device at time.

(ok its bit unsafe to controll with arduino... buuut :smiley:

What happens if you do the digitalWrite() before the pinMode() ?

Turn the two statements around.

UKHeliBob was faster :frowning:

...I feel silly, I didnt even thought that option. gonna try at asap.

Normal relays take milliseconds to operate, a brief glitch of a few microseconds won't matter at all....

The problem is more likely to be that the 5V rail on the Arduino rises slower than the power to the relays, such that the Arduino pin is still held low by the Arduino 5V rail as the relay power becomes high enough to operate.

Switch-on glitches like this typically last many milliseconds, easily enough to click a relay.

The only fix if this is the problem is to add some sort of delay logic to the signals that's controlled by the Arduino 5V reaching safe levels.

Thinking about it some more this shouldn't be an issue if the relay modules are connected
correctly, with the 5V for the optos coming from the Arduino... Perhaps you should post
your circuit, it could be something else entirely.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.