PIN port high impedance state? Output to input

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);
// 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 ++. :persevere:


How can I do so that if MOD is true, the PIN is read, and if it is false it is written?

struct State {


constexpr Number pwmRange = PWMRANGE;
constexpr Number pwmRange = 255.0;

void evaluate(Context ctx) {
    if (!isInputDirty<input_UPD>(ctx))

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

    if (!isValidDigitalPort(port)) {
        emitValue<output_ERR>(ctx, 1);

    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);

I think I got it, apparently it works

if (enable) {
::pinMode(port, OUTPUT);
} else {
::pinMode(port, INPUT);


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.