Hello, can you use a port PIN as an output and then as an input?
there is some way in XOD
for example:
digitalWrite (3, OUTPUT, ANALOG);
delay(300);
// Puts PIN 3 in a high impedance state
digitalWrite (3, LOW);
pinMode (3, INPUT);
How could I add a control using an if
in C ++? I do not finish understanding the syntax, it’s different from what I find about C ++.
How can I do so that if MOD is true, the PIN is read, and if it is false it is written?
struct State {
};
{{ GENERATED_CODE }}
#ifdef PWMRANGE
constexpr Number pwmRange = PWMRANGE;
#else
constexpr Number pwmRange = 255.0;
#endif
void evaluate(Context ctx) {
if (!isInputDirty<input_UPD>(ctx))
return;
const uint8_t port = getValue<input_PORT>(ctx);
if (!isValidDigitalPort(port)) {
emitValue<output_ERR>(ctx, 1);
return;
}
auto duty = getValue<input_DUTY>(ctx);
duty = duty > 1 ? 1 : (duty < 0 ? 0 : duty);
int val = (int)(duty * pwmRange);
::pinMode(port, OUTPUT);
::analogWrite(port, val);
emitValue<output_DONE>(ctx, 1);
}