write(analog-ports)

koadrobot/ports/write(analog-ports)

No description
write(analog-ports)
@/write(analog-ports)
P3boolean
P5boolean
P6boolean
P9boolean
P10boolean
P11boolean
DUTYnumber
Value in range 0 … 1
PULLboolean
Hardware connection. pulldown (true) - High, pullup (false) - Low (1-duty).
UPDpulse
Triggers new write
write(analog-ports)
P3
P5
P6
P9
P10
P11
DUTY
PULL
UPD
DONE
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))
    {
        Number duty = getValue<input_DUTY>(ctx);

        duty = (duty<0) ? 0 : (duty>1) ? 1 : duty;

        int val = (int)(duty * 255);

        if (!getValue<input_PULL>(ctx)) val = 255 - val;

        if (getValue<input_P3>(ctx))  ::analogWrite(3, val);
        if (getValue<input_P5>(ctx))  ::analogWrite(5, val);
        if (getValue<input_P6>(ctx))  ::analogWrite(6, val);
        if (getValue<input_P9>(ctx))  ::analogWrite(9, val);
        if (getValue<input_P10>(ctx)) ::analogWrite(10,val);
        if (getValue<input_P11>(ctx)) ::analogWrite(11,val);

        emitValue<output_DONE>(ctx, 1);
    }

}