# 4n25/35 optocoupler detect led on/off

Hey all i am just wondering if my drawing below is correct in order to have an arduino detect an on or off led on another board using a optocoupler?

My thoughts of the above drawing is that when the led is on it will trigger the relay inside and send 5v to the arduino digital pin to read. 0v if the relay inside is not connected.

I also would possibly need to tell the arduino digital pin that its an input pullup like this:

pinMode(pin, INPUT_PULLUP);


Im looking to connect the 4n25 to a HM-10 bluetooth module led:

• One issue is you cannot just put the optoisolator’s LED directly in parallel with another LED. The optoisolator LED is probably infrared which has a voltage drop lower than any visible LED. This means that with the opto connected, the visible LED will not receive its minimum voltage and will not light. What you need to do is find the series resistor of the LED and connect the opto and a series resistor in parallel with original resistor and LED. – DoxyLover Oct 18 '17 at 5:48

simulate this circuit – Schematic created using CircuitLab

Figure 1. A typical opto-isolator configuration.

My thoughts of the above drawing is that when the led is on it will trigger the relay inside and send 5v to the arduino digital pin to read. 0v if the relay inside is not connected.

Close, but not quite right.

• It's not a relay; it's a transistor.
• It will send 5 V to the micro if wired as in (a) and zero if wired as (b).

I also would possibly need to tell the Arduino digital pin that its an input pullup like this:

pinMode(pin, INPUT_PULLUP);


That is correct for (b). For (a) you need to pull down.

The idea of the pull-up / down is that when the opto-isolator is turned off you want to pull the input to the opposite rail that the opto-transistor is wired to.

• Thanks for the reply, @Transistor. Whats the purpose of having the R1 and R2? And so for (a) the Anode would be the "sw1" and it would just be connected to ground? – StealthRT Oct 18 '17 at 5:41
• R1 and R2 limit the current through the LED to the required value (obtained from the opto-isolator datasheet). I don't understand the second part of your comment, but the anode certainly would not be connected to ground. I have shown the anodes of the opto-LEDs connected to the positive supply through a switch and the cathodes (negative) connected through a resistor. The order of switch, LED and resistor doesn't matter but the LED anode must be connected towards the positive supply. – Transistor Oct 18 '17 at 6:14
• @StealthRT ... I believe Transistor was confusing R2 with R3. R2 establishes a logic low-level when Q1 is off. – Tut Oct 19 '17 at 11:27
• @Tut is right. Transistor was confused. Correction: R1 and R3 limit the current through the LED to the required value. – Transistor Oct 19 '17 at 11:29
• @Transistor can you redesign your schema then to show this for me? – StealthRT Oct 20 '17 at 14:08