1

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? Commented Feb 15, 2016 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. Commented Feb 15, 2016 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 Commented Oct 24, 2017 at 8:57

1 Answer 1

6

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.