Part

Optocoupler, 4N35

An infrared LED and a phototransistor in one DIP-6, with no wire between them: switch a circuit you cannot connect to.

See every part
  • 6 pins
  • 1 setting
  • In 1 project
Drawn live by the editor's own code, at the size you see it.
Optocoupler, 4N35 as drawn in the Mokxi simulator
At a glance

The Optocoupler, 4N35 in brief

What it is, and every setting the properties panel gives it.

An optocoupler is an infrared LED and a phototransistor sealed in one black DIP-6, facing each other across a gap of clear plastic. Current through the LED makes light, the light turns the transistor on, and the two sides share no wire, so the circuit on the transistor side can have its own supply and ground. That is the whole point, and it is how the Arduino Starter Kit’s Hacking Buttons project presses another gadget’s button. The Mokxi part is the 4N35, and the four-pin PC817 on relay modules works the same way. The LED is an infrared one, 1.2 V at 10 mA and about 1.35 V at 50 mA. The transistor’s light comes from the LED current, so its collector current is the CTR percentage times the LED current, 120 percent by default, and if asked for less it saturates at about 0.1 V. The base pin is left open, and switching time, aging and the isolation voltage are not modeled.

Family
Timers and analog
Pins
6
ctr
120
Pins

6 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
A
1
K
2
NC
3
E
4
C
5
B
6
How to use it

How to use a 4N35 optocoupler with an Arduino

The project keeps two circuits apart. On the Uno side, pin 2 goes through a 220 ohm resistor to A, the LED’s anode, and K goes to the Uno’s ground. That is about 17 mA. On the other side, two AA cells, a 330 ohm resistor and a red LED stand in for the gadget, and the transistor’s C and E go where its button would: collector toward the more positive side. Every two seconds the sketch takes pin 2 high, the infrared LED lights, and the far LED comes on with no wire between the two.

The LED is an LED, so it wants its resistor. Without one a pin pushes as much current as it can, far past the rating. Pin 3 is not connected on the real part either, and the base, pin 6, is left open in the model, so anything wired to B has no effect.

The CTR, current transfer ratio, is the collector current per milliamp of LED current at the datasheet’s test point. Vendors guarantee at least 100 percent, and the model defaults to 120. A transistor asked for less than that saturates, about 0.1 V collector to emitter, which is the pressed state a button needs. It is a transistor, not a contact: wired backward across a button it barely conducts, and it is good for tens of milliamps, so to switch more use it to drive a transistor or a relay.

Part pin
Board pin
A (pin 1)
Uno pin 2, through 220 ohms
K (pin 2)
Uno GND
NC (pin 3)
Not connected, on the real part too
C (pin 5)
The gadget’s more positive side, here the cells through 330 ohms and the LED
E (pin 4)
The other side, here the cells’ minus
B (pin 6)
Left open

On a 3.3 V board use a smaller resistor for the same LED current: (3.3 V minus about 1.2 V) over 10 mA is about 210 ohms, so 220 ohms gives roughly 10 mA.

Arduino Uno: pressing a button through a 4N35live0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
A press every two seconds
const int OPTO_PIN = 2;

void setup() {
  pinMode(OPTO_PIN, OUTPUT);
}

void loop() {
  digitalWrite(OPTO_PIN, HIGH);   // "press"
  delay(300);
  digitalWrite(OPTO_PIN, LOW);    // "release"
  delay(1700);
}
Common errors

Common Optocoupler, 4N35 errors and fixes

What goes wrong
The fix
The pin is wired straight into the LED.
Put a resistor in series, such as 220 ohms from a 5 V pin for about 17 mA. Without it the pin pushes more current than the LED can take.
The transistor side barely conducts.
Collector and emitter are the wrong way around across the gadget’s button. The collector goes to the more positive side. It only carries current one way.
Something wired to pin 6 changes nothing.
The base is left open in the model, as in most hobby circuits. On a real 4N35 a resistor from B to E can speed up switching, but it is not modeled.
A motor or a mains load connected to the transistor does not work.
The transistor handles tens of milliamps. Use the optocoupler to drive a transistor, a MOSFET or a relay, and keep the load on that.
Questions

Questions and answers

What is an optocoupler used for?

To pass a signal between two circuits with no electrical connection. The LED lights, the phototransistor conducts, and the two sides can have separate supplies and grounds.

What is CTR?

The current transfer ratio: collector current per milliamp of LED current, in percent, at 10 mA and 10 V. Every vendor guarantees at least 100 percent for a 4N35. The model defaults to 120.

Why does the LED need a resistor?

It is an infrared LED with a forward drop of about 1.2 V. Without a resistor, a pin drives current limited only by the pin, far above the part’s rating.

Does the model enforce the isolation rating?

No. The two sides are separate circuits with no path between them, and the isolation voltage is unlimited in the simulation. A real part has a limit.

How it is modeled

What is true about the Optocoupler, 4N35, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

Isolation. The LED side and the transistor side are separate circuits with no path between them, so each can have its own ground.

The LED's drop. It is an infrared GaAs LED, not a visible one: 1.2 V at 10 mA and about 1.35 V at 50 mA, from the 4N35 sheets (1.5 V maximum). Under about 1 V it passes almost nothing.

The current transfer ratio. The transistor's light comes from the LED current, solved in the same step, so its collector current in the active region is ctr times the LED current at the test point: every vendor's 4N35 guarantees at least 100 %, and the default of 120 % is an assumption just above that floor. A transistor asked for less than that saturates, about 0.1 V from collector to emitter, which is the "pressed" state a button circuit needs.

It is a transistor, not a contact. Wired backwards across a button (emitter to the positive side) it barely conducts, and it only carries current one way.

Not modeled

The base pin: the 4N35 brings the transistor's base out on pin 6 so a resistor to the emitter can speed up switching. Here the base is open inside, as in most hobby circuits, and anything wired to B has no effect.

The switching time (a few microseconds), the CTR's fall at very low and very high LED currents and as the part ages, temperature, and the isolation voltage, which here is unlimited.

From Optocoupler (4N35), in full.

Projects

See the Optocoupler, 4N35 in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

The boards it is shown on

This board has a built-in project with the Optocoupler, 4N35 in it.

Wire up the Optocoupler, 4N35

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.