This graphic shows how a basic optocoupler works. First, an electric current turns on the infrared emitting diode. The light from this diode travels through IR transparent epoxy to a photo detector, in this case a phototransistor. Current is generated by the phototransistor and this current is then used in various circuits. Light can travel between the emitter and detector but electricity can not because there is no direct metallic connection. They are galvanically isolated.