0

Is it possible to change pin operation from output to input within the Arduino loop (event-driven)?

I would like to change the operation of a couple of Arduino pins from input to output during execution of the Arduino loop in an event-driven way. Is this possible please?

3
  • How do you mean "in an event driven way"? The Arduino has no events - maybe you are using some other software?
    – Majenko
    Feb 15 '16 at 18:24
  • I mean that the functioning of certain pins as input or output would 'depend' upon some condition, some event happening one one of the other input pins.
    – pascalm
    Feb 15 '16 at 19:08
  • The answer above is correct but the syntax is wrong (atleast to my knowledge). The correct syntax is pinMode(pin, mode) copied from the original arduino.org post.Note:If I am wrong pls correct me Oct 24 '17 at 8:57
3

Yes.

Just call pinMode([pin], [mode]) whenever you want to change from input to output or output to input.

How to decide when to do that is entirely up to you. You can do it any time you choose using any stimulus you like.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.