cesars/motor
#pragma XOD error_raise enable struct State { }; {{ GENERATED_CODE }} void evaluate(Context ctx) { if (!isInputDirty<input_ACT>(ctx)) return; const uint8_t port1 = getValue<input_1A>(ctx); const uint8_t port2 = getValue<input_1B>(ctx); if (!isValidDigitalPort(port1) || !isValidDigitalPort(port2)) { raiseError<output_DONE>(ctx); return; } ::pinMode(port1, OUTPUT); ::pinMode(port2, OUTPUT); const bool val1 = getValue<input_FORW>(ctx); const bool val2 = getValue<input_BACKW>(ctx); if (val1 > val2){ ::digitalWrite(port1, 1); ::digitalWrite(port2, 0); }else if(val1 < val2){ ::digitalWrite(port1, 0); ::digitalWrite(port2, 1); }else{ ::digitalWrite(port1, 0); ::digitalWrite(port2, 0); } emitValue<output_DONE>(ctx, 1); }
© 2017–2024XOD Inc
Contact us: hello@xod.io