pinMode setting issue

Issue #431 resolved
Sean shao created an issue

When a pin is used as an output pin and then reconfigured as an input pin in the program, it does not work properly. To reassign the pin mode as a digital input, it is necessary to unplug and re-plug the USB cable.

Comments (8)

  1. John Maloney repo owner

    Switching pin modes should work, and does on most boards. What board are you using?

    Are you setting the output pin to true/false or to a number?

    When you switch to using the pin as an input, what does it do and what did you expect it to do?

    Could you provide a short example that demonstrates the problem?

  2. Sean shao reporter

    First, set the pin output as digital output, then change it to analog output, and then switch back to digital output. Switching several times will make the pin's digital output fail.

  3. John Maloney repo owner

    I thought the issue was probably analog output.

    For some reason, the Arduino library does not have a way to turn off analog output on a pin once it is started.

    The pilot release has a work-around for that issue but, from the video, I think you are already using a version of MicroBlocks with the work-around.

    Thank you for creating that video! From watching that, I see that there may be a problem when you switch between digital and analog output several times. I will try to reproduce it.

  4. Log in to comment