Write, then read on same pins

So I know that in one section of a code one can write to a pin, then later on, read from that same pin.

I have a dc motor on a linear actuator and the way it works is when you put 12V to the DC motor the actuator travels in one direction, then when it reaches its end of travel it just stops, even with power still connected to the terminals of the motor. I want to use a relay module (octocoupled) that when the pin I assign goes high, it closes the circuit between 12V from a tractor battery and the forward terminals of a DC motor controller. Aside from running that command through a timer setup, or adding a limit switch, is there any way that I can read that stop from the actuator and use that to tell my mega2560 to send that pin LOW? Or do I just setup and run a timer command for the duration of the travel?

If the actuator breaks the circuit, you should be able to detect that with a current detector or opto-isolator.

Note there is no need to use the same pin, in fact you can’t in this case. But you don’t seem to be asking what your thread’s title implies, that is using the same pin.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.