# 4n25/35 optocoupler detect led on/off

Status
Not open for further replies.

#### StealthRT

##### Member
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:
Code:
pinMode(pin, INPUT_PULLUP);

#### MikeMl

##### Well-Known Member
It might work if you use the Opto coupler's transistor to pull the Arduino's input pin to ground. If the opto is off, the internal pull-up in the Arduino pulls the input pin high. If the opto is on, it sinks current, and pulls the input pin low.

#### Pommie

##### Well-Known Member
You should use a separate current limiting resistor in case the LED in the opto has a higher on voltage than the one it's in series with.

Mike.

#### StealthRT

##### Member
im looking to hook up the 4n25 to an hm-10 led:

#### Pommie

##### Well-Known Member
If you connect your opto directly across the blue LED (Vf ≈3.3V) it will hog all the current and the blue LED will never light. If that is ok then do it that way. If not then connect the opto in series with a resistor between PIO1 and Gnd. Check data sheets for current available on PIO1 and needed by opto.

Mike.

#### ci139

##### Active Member
if you current mirro your led ? perhaps by some ratio to opto input ... would be quite fast (i assume)

◄click to follow
to get - the image applies to http://www.vishay.com/docs/81864/4n25x000.pdf -- ****
then it takes to check the http://www.farnell.com/datasheets/2047068.pdf
to see that the company uses to mark the product from the same family so thet the text is oriented from least / highest pin no. toward the middle ones ...
so it takes one to two test to tell which is the case with 4N25
----------
note **** the datasheet shows characteristic graphs starting from 100µA iR-Led (Transmitter) current (IFW at legends) which has proven to be the case and in practice for xx817xx -s
----------
with uno

Last edited: