write(digital)

koadrobot/ports/write(digital)

No description
write(digital)
@/write(digital)
PORTport
Digital port to read from. Should start with `D` to succeed.
SIGboolean
State to write
UPDpulse
Triggers new read
PULLboolean
Hardware connection. pulldown (true) - High, pullup (false) - Low (1-duty).
write(digital)
DONE
ERR
PORT
SIG
UPD
PULL
ERRpulse
Fires if write failed. E.g. `PORT` does not exist.
DONEpulse
Fires on writing complete
To use the node in your project you should have the koadrobot/ports library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx)
{
    if (isInputDirty<input_UPD>(ctx))
    {
        const uint8_t port = getValue<input_PORT>(ctx);

        if (isValidDigitalPort(port))
        {
            ::pinMode(port, OUTPUT);

            bool val = getValue<input_SIG>(ctx);

            if (getValue<input_PULL>(ctx))
                ::digitalWrite(port, val);
            else
                ::digitalWrite(port, !val);

            emitValue<output_DONE>(ctx, 1);
        }
        else
            emitValue<output_ERR>(ctx, 1);
    }
}