How to use pins as Input and Output "AT THE SAME TIME". This is how.

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.

Not really "at the same time", but does isolate your input & output signals. The Input does not need to be a latch, just a buffer with Output enable that you can control, and then use the Arduino to latch the signals, this saving an IO pin.

Or, both parts can be shift registers (such 75L165, in, and 74HC595, out) so you can read/write serially to both and save on pins.

What you have drawn is a conventional data bus arrangement that was used to build all microprocessor systems until the all in one chips came along. This is the way I/O was done on many processors with also RAM and ROM hanging off this bus.

So it does not fulfill the "at the same time" criteria you are just using the bus lines as a time division multiplex.

I fully agree.

However, it is difficult to get inflections in electronic format.

Thus the quotes around "AT THE SAME TIME".

Someone, in a post here which I once found, was having all sorts of trouble getting something like this working and need help.

I took the time to try and explain how to do it in as simple a way as possible yet still be useful.

Right now I am still way out of my depth with programming and understanding what I am doing but am slowly making ground with my "alarm clock" sketch.