Usually, if you have to share inputs for limit switches you would connect normally closed switches/sensors (which you seem to have) in series (24 volts) and configure your controller to error on the loss of signal. I would have a 5 volt signal from the Arduino wired to your input pin that is switched on and off by the 24 volt circuit. Maybe use an optoisolator that can accept a 24v signal that switches 5v might do the trick.