If you get a very cheap optocoupler (.25usd) you can run 12-24 volts into the LED, just use something like a 470- 560 ohm resistor before the LED. The transistor side usually will only have 2 pins on a quad opto IC( collector = voltage in, emitter = voltahe outwhen switched on), so run 5 volts into the collector, the output will be 5 volts, and will be completely isolated from the source as light is turning on the transistor, not a wire. Conversly, to get 12 volts from 5 for example, use the reverse, 5v goes into the LED, 12v is on the transirstor collector, the output is 12v whent he LED is on. This is a great method where isolation is required to prevent damage. There are different speeds of opto's, so if using high speed signals get a fast opto.
If you need the output of the opto to be 5v/0v logic, you must tie the output of the opto to GND with a 10k, otherwise it will float and you will have logic problems.