switching from receive to transmit on the fly

Hi Folks! Even though I am retired, I don't believe I have enough time to read the over 2000 pages of questions and answers in this topic in the forum, so I will ask and hope someone can guide me in the right direction. I want to have my program default to receive mode using one pin as input on the Uno with the Virtual Wire library but be able to switch to an output pin and be used as an output pin for transmit. Can the Uno pins be re-designated on the fly from within a running program and then switched back to input after the transmission is complete? Thanks. Brian

Rather than read 20000 pages (many more than 2000, I suspect) why not read the Reference section here

AFAIK the Wire library is for two-way communication so I don't understand your question


Robin2 The virtual wire program allows me to use a pair of 433Mhz modules, one for transmit and one for receive. These modules have three pins, Vcc, ground and data. What I want to do is use the same pin on the Uno for transmit data at one time in the program and receive data at another time in the program. What I need to know is can the function of the pins, that is INPUT or OUTPUT be changed during the running of the loop in the program to accommodate these two different actions? Thanks. Brian

It is possible. To illustrate how its done, the Ping library for the 3 pin rangefinders does just what you are asking. One pin is used for both trigger (output) and to sense the echo (input). The pin is set to output to trigger the rangefinder then that same pin is switched, in the running code using pinMode, to input to receive the echo.

groundfungus, Thank you very much. You have saved me a lot of time searching through everything to find an answer. I appreciate that. Brian

kingbf: The virtual wire program allows me to use a pair of 433Mhz modules, one for transmit and one for receive.

Are these modules bi-directional ? OR have you two modules - one for transmitting and the other for receiving? And are you wondering whether you can connect the data pin from each module to a single Arduino pin ?

AFAIK I2C can be used to connect several devices to the same pin - each device needs a separate address.


How will you turn off the Receive module so it doesn't interfere with your transmitting? I'd suggest using part like 74HC125 - put one between Receiver and the pin, and a 2nd between the pin and the transmitter. When uC is sending, disable the receive buffer. When uC is receiving, disable the transmit buffer and use a 10K pulldown on the output so the transmitter is not sending out junk from a floating input.