How to invert Arduino Manager switch output

I have setup the remote-controlled PSU, but I want the "off" position in Arduino Manager to be high and "on" to be low, since the PSU's control wire needs to be pulled low to turn on. How do I do this?

Use a transistor or a MOSFET to invert level.
RV mineirin

You can use the not operator. This operator can be used inside the condition of an if statement. if (!x) { // if x is not true // statements }. It can be used to invert the boolean value.

Use #define to set constants for on and off.

#define on 0
#define off 1

Then you can digitalWrite(powerSupplyPin, on); to send a 0 to the pin that controls the power supply or digitalWrite(powerSupplyPin, off); to send 1 to turn it off.

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