Trying NOT to short things out!

Here's a drawing that might help you out. Remember to use the datasheet for the optocoupler that you decide to use and calculate the right resistor values

(updated image)