Send and receive on the same pin

Is it possible to use a single digital pin for both writing and reading data?

I want to implement a certain protocol. This protocol sends messages to another device and in some cases this other device must respond on the same line. Is this at all possible with an Arduino?

Sure, you can change the mode of the pin on the fly.
Maybe you start with side set as Tx and the other as RX. At some point the TX side says “send me something in 5mS”. Then the Tx side runs pinMode and changes its output to an input and starts listening. At the same time, the Rx side runs pinMode and sets its input to an output, waits for the 5mS to elapse, then sends the something. Then it runs pinMode back to input and goes back to listening. The original Tx side receives the something goes back to Tx mode, maybe tells the Rx that something was received correctly, maybe not, whatever your protocol calls for.

tbscope: Is it possible to use a single digital pin for both writing and reading data?

I want to implement a certain protocol. This protocol sends messages to another device and in some cases this other device must respond on the same line. Is this at all possible with an Arduino?

Your are free to change a I/O pin 'on the fly' with the pinMode() command. However you have to be very careful how you coordinate it with both sides of the signal line, in that if ever both sides are output mode at the same time and one is high and the other is low, there will be a short circuit condition and would burn out one or both pins. Best to wire a series 200 ohm resistor between the two pins and then there can be no damage. Also if both sides pins are set to input mode at the same time, then you will have a 'floating' input condition and reading the value will be random errors values due to noise. An external pull-up or pull-down resistor will prevent that condition. Finally note that there needs to be a common ground wire run between the two sides for any of this to work.

Lefty

Thanks for the information.

The Arduino will be the master (there can only be one master in this protocol), the other device never sends anything without being asked. And there must a certain amount of time between each packet.

I'll try it with switching the input/output mode.