servo-rotate-true

g4sasha/fix-servo/servo-rotate-true

Turns on and turns the servo when the True signal is applied to it
servo-rotate-true
@/servo-rotate-true
Turns on and turns the servo when the True signal is applied to it
PORTport
VALnumber
Desired servo angle or value in unit range [0.0, 1.0]. For standard servo 0.0 would be mapped to 0° and 1.0 would be 180°.
ENboolean
Enable servo. Detach servo if this is false.
servo-rotate-true
PORT
VAL
EN
DONE
DONEpulse
To use the node in your project you should have the g4sasha/fix-servo 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

{{#global}}
#include <Servo.h>
{{/global}}

struct State {
    Servo servo;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    State* state = getState(ctx);
    auto port = (uint8_t)getValue<input_PORT>(ctx);
    auto EN = getValue<input_EN>(ctx);

    if (EN) {
        state->servo.attach(port);
        state->servo.write(getValue<input_VAL>(ctx) * 180);
    } else {
        state->servo.detach();
    }
}