Electrical – 4n25/35 optocoupler detect led on/off

arduinoatmega32u4ledopto-isolatoroptoelectronics

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

Best Answer

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.