I have an old device that contains multiple buttons that are all tied to some connectors in the back. The connectors are hooked up to a computer that interprets each button press and sends out a command depending on what button was pressed. When the buttons are depressed, there is a constant 24V DC voltage coming out of the corresponding pin from the connector. When the button is pressed, the voltage on that same pin quickly changes to -24V DC. I am in the process of upgrading the hardware in the computer and the IO modules can only accept a range of 0 to +5V. I am trying to figure out a way that I can step down the +24V down to about +5V and convert the -24V to something close to 0 so that the computer modules can interpret that as a low. Because of the positive and negative voltage toggling through a single wire, I am assuming that I just require a single converter. I am so confused as to how I can even work this out or if it is even possible. Any help would be greatly appreciated.
It's called a "DC clamp" circuit:
The Schottky diodes prevent the right-hand side from dropping below 0V or rising above 5V. If the left-hand side exceeds this range, the diodes conduct, and the excess voltage is dissipated in the resistor.
The forward voltage drop of the diodes is about 0.3V, so the final voltage range you get is -0.3V to +5.3V, which is usually acceptable to equipment that nominally requires a "0 to +5V" range.
You could also employ a Zener if that's your cup of tea.
This will be slightly more conservative than Dave's -- the output will be 0V to just under 5V (the 1N4732A is 4.7V) -- if you're worried about the extra 0.3V. But you'll pay: this design uses two different devices plus and an extra resistor.