0
\$\begingroup\$

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?

enter image description here

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);

please advise if this is correct or not.

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

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – DoxyLover Oct 18 '17 at 5:48
4
\$\begingroup\$

schematic

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – StealthRT Oct 18 '17 at 5:41
  • \$\begingroup\$ 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. \$\endgroup\$ – Transistor Oct 18 '17 at 6:14
  • \$\begingroup\$ @StealthRT ... I believe Transistor was confusing R2 with R3. R2 establishes a logic low-level when Q1 is off. \$\endgroup\$ – Tut Oct 19 '17 at 11:27
  • \$\begingroup\$ @Tut is right. Transistor was confused. Correction: R1 and R3 limit the current through the LED to the required value. \$\endgroup\$ – Transistor Oct 19 '17 at 11:29
  • \$\begingroup\$ @Transistor can you redesign your schema then to show this for me? \$\endgroup\$ – StealthRT Oct 20 '17 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.