I'm creating a logic based circuit and below is my schematic.

The circuit first steps down a 24 VDC input to about 3.7 VDC using a 150 kΩ resistance and a 5.1 V Zener diode.

This 3.7 VDC is fed to the input of optocoupler PC817 pin 1 and 2.

On the output, I wanted to read the high and low through an Arduino connected to pin 3 and 4 of the optocoupler. I was planning to pass in 5 VDC from the Arduino to one of its digital I/O pin through the optocoupler.

Is there anything wrong here? I'm not able to read the high on the output of the optocoupler. I checked that the voltage around pin 1 and 2 is 3.7 V.

Schematic showing the circuit with Optocoupler


I reduced the resistance to about 4 kΩ since i didn't have the exact 4.7 kΩ as mentioned in the comments below. I also tried 5.6 kΩ, however seems like the optocoupler doesn't work in any case.

  • 1
    \$\begingroup\$ Welcome to EE.SE! Have you calculated the LED current going to your 817 and compared it with the values listed as recommended operating conditions in the datasheet? \$\endgroup\$
    – winny
    Jan 4, 2020 at 11:10
  • \$\begingroup\$ After your schematic is still showing reverse supply connection to the LED as pointed out in the comments below. If you really want useful answers you need to show your actual circuit with correct pin-out and component values. It's not clear how you think a 5.1 V Zener will protect an infrared LED with a typical forward voltage of about 1.4 V. \$\endgroup\$
    – Transistor
    Jan 4, 2020 at 14:01
  • \$\begingroup\$ How are you connecting the Optocoupler output to the Arduino? Your description is not very clear. \$\endgroup\$
    – StarCat
    Jan 4, 2020 at 21:02

2 Answers 2


Something like this should work in most situations (with low switching frequencies, up to a few kHz or so):


simulate this circuit – Schematic created using CircuitLab

This produces a non-inverted output.

If you need the output to be inverted, connect pin 3 to GND, connect the Arduino input to pin 4 and put a pull-up between pin 4 and +5V. I'm assuming your Arduino runs on 5V.

  • \$\begingroup\$ can we omit the pulldown resistor and configure the input port with an internal pulldown? What's the disadvantge? \$\endgroup\$
    – Hacky
    Dec 16, 2022 at 11:02
  • \$\begingroup\$ That would probably work, but because internal pulldowns are generally weak, switching times will increase and the maximum switching frequency will be lower. \$\endgroup\$
    – StarCat
    Dec 16, 2022 at 16:38

The input to optocoupler is wrong, pin 1 is the anode (positive) and pin 2 is the cathode (negative). Also 150k resistor does not provide enough current to light up the optocoupler LED, change the resistor to 4.7 kilo-ohms to provide about 5mA at 24V. You can also throw away the zener, it is useless.

  • \$\begingroup\$ I changed the input polarity but this time the voltage across pin 1 and 2 is 0.6v. \$\endgroup\$ Jan 4, 2020 at 11:35
  • \$\begingroup\$ Then you should update the schematic. A wrong question will get wrong answers. \$\endgroup\$
    – Transistor
    Jan 4, 2020 at 11:39
  • \$\begingroup\$ I updated my answer, LED current is obviously too low for it to work. You might want to draw how you connected it to Arduino, as you might have that wrong as well. \$\endgroup\$
    – Justme
    Jan 4, 2020 at 11:55
  • \$\begingroup\$ 0.6V is correct if you reversed the 24V input. Think about it. You're now forward biasing the zener, \$\endgroup\$
    – SteveSh
    Jan 4, 2020 at 11:56
  • \$\begingroup\$ Why do you think you need the zener? All you really need is the right value resistor, though good design practice usually adds a couple of more components for robustness and protection. \$\endgroup\$
    – SteveSh
    Jan 4, 2020 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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