Optocouplers
Sometimes two circuits must pass a signal but share no connection: a microcontroller switching something on the mains, a medical sensor on a patient, a long cable whose ground at the far end is several volts different from yours. Send the signal as light.
An optocoupler is an infrared LED and a phototransistor (a transistor whose base current is made by light, a photodiode with gain) sealed in one package. Inside the package, the LED and the phototransistor face each other across a gap of clear insulating plastic. In the drawing, each circuit has its own battery and its own ground, and no wire crosses between them. Flip the switch: the LED lights, its infrared light crosses the gap, and the light turns the transistor on, so current flows on the output side and its output falls.
The bench has the same two circuits: a 5 V side with a switch (the lower half of the board), and a 9 V side with its own battery (the upper half). Nothing joins them.

- Light from the LED, through clear plastic inside the package
- A wire inside the package
- A magnetic field
- Radio
Put the PC817 across the channel: its LED's anode (pin 1, by the dot) in E20 and cathode in E21, so its transistor's collector is in F20 and emitter in F21. Then a 470 Ω resistor from the switch's middle pin (column 17) to the LED's anode, column 20. Press Run and flip the switch.
On a real bench the isolation only works if the board keeps the two sides apart too. Their tracks must be separated by the distance the datasheet gives (several millimetres for mains). A breadboard's strips are 2.5 mm apart, so a breadboard gives no real isolation: use it only for low-voltage tests like this one.
An optocoupler's CTR, current transfer ratio, is how much collector current it passes per unit of LED current: a PC817's is typically around one, but it varies several times over between parts, and falls as the LED ages. Here the LED carries about 8.09 mA. To pull the output fully down, the transistor must sink the pull-up's current, 9 V / 10 kΩ. What's the least CTR that does it?
Answer in ×.
An optocoupler:
- an LED and a phototransistor in one package: the signal crosses as light, across an insulating gap of thousands of volts;
- the two sides share no connection: each has its own supply and ground;
- its CTR (output current per LED current) varies widely and falls with age: design for the worst;
- fairly slow (microseconds), so fast data uses special high-speed couplers.