kpot(duty)

koadrobot/devices/kpot(duty)

No description
kpot(duty)
@/kpot(duty)
PORTport
Analog port to read from. Should start with `A` to succeed.
UPDpulse
Triggers new read
kpot(duty)
DUTY
DONE
ERR
PORT
UPD
ERRpulse
Fires if update failed. E.g. `PORT` is not an ADC port.
DONEpulse
Fires on writing complete
DUTYnumber
To use the node in your project you should have the koadrobot/devices 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))
        return;

    const uint8_t port = getValue<input_PORT>(ctx);

    if (isValidAnalogPort(port))
    {
         Number val = :::analogRead(port) / 1023.;

        emitValue<output_DUTY>(ctx, val);

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