Hi again folks.
I know this topic has come up a few times and I found a thread once but now can’t find it again.
Someone was asking how you can use pins as BOTH input and output AT THE SAME TIME.
Although not perfect: This is one method.
It only works for DIGITAL signals. Analogue ones are trickier, but with a bit of extra stuff, I am sure it could be done.
Ok, the name I use in the schematic is maybe not the best name, and there may be a couple of other signals needed, but this is the guts of it.
Your outputs and inputs go via a latch/buffer so that the data is only passed through when the chip is “ENABLED”.
Granted that may be an old term, but that’s how I learned (learnt?) it.
When you want to send an output, you activate the pins on the Arduino and also on another couple of pins to allow what the Arduino is “saying” to be repeated on the outputs of the LATCH.
Once, the signals are there, you “disable” the chip from looking at the inputs and the outputs stay as they are.
Then, to use the same pins as INPUTS, you re-define them as inputs, and “enable” another chip, similar to the first one, where its outputs are then reflected to the pins of the Arduino.
Granted with this chip, there is an extra signal needed so when the chip is “inactive” (that is you are using the Arduino as an OUTPUT) the pins are “HIGH IMPEDANCE” and they don’t have any output.
Again, the schematic is somewhat basic, and you will need a different chip on the input as to the output, but again: This is the basics, or the guts of it as I said earlier.