Is there code for Making a Digital output NEUTRAL - NOT HIGH OR LOW - Floating OUTPUT

Is there "code" for Making a Digital output NEUTRAL - NOT HIGH OR LOW - Floating OUTPUT.

1 Like

Hi,
Yes there is...

1 Like

make it INPUT ... and it will be NEUTRAL as you want

1 Like

Switch to input? That will make it tristate.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with nor for advice on your project.

1 Like

Is there a way to do it within the code and still use it as an output when needed.
Like adding code in the active loop.
Sometimes I need a HIGH output, but I don't want to make it LOW to change it.
Simply make it NEUTRAL for the rest of the code and back to a OUTPUT the next time in runs.
I would like to be able to do this for each of the output pins (4 in this case).
.

Use pinMode().

It is allowed anywhere, not just in setup().

a7

// Sometimes I need a HIGH output
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);

//  I don't want to make it LOW to change it.
pinMode(pin, INPUT);    // Simply make it NEUTRAL

// and back to a OUTPUT
pinMode(pin, OUTPUT);
2 Likes

What do you want to achieve?
How will the receiver read the state?
NEUTRAL will be read as either HIGH or LOW with digitalRead. But you can never know beforehand...

1 Like

Yes.

This is often done when you want an open drain in a design.

See

That would make sense...

Just put a diode in series with output ? ( if you never want a “ low”)

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