I have tried this three schematics (pictures below), and they all seem to be working mostly the same. So I can't choose which one to use, and what are the advantages/disadvantages. Any ideas ? P.s. I use CNY70 as light sensor, and the MCUpin goes into Atmel AVR microcontroller digital input.

Version 1 Version 2 Version 3


The resistor in series with the opto's LED can be on either side of the LED, with no effect on the operation of the circuit.

In the first circuit, MCUPIN will be high when the LED is on.

The second circuit will also pull MCUPIN high when the LED is on, but there will be an extra 0.7 volt drop due to the extra transistor.

The third circuit will pull MCUPIN low when the LED is on.

In my opinion, the extra transistor is unneccessary (unless you need the inversion of circuit 3), as the opto should be able to drive an MCU input directly.

| improve this answer | |
  • \$\begingroup\$ so the thing that connecting without transistor is not stable is bs ? \$\endgroup\$ – hingev Jun 2 '14 at 19:48
  • 1
    \$\begingroup\$ If the micro is running from that same +5V power rail, then no transistor should be necessary. Circuit 2 is not very good (max output is less than 4.7V) and Circuit 3 inverts the signal. The only reason you'd want to use a transistor here is to either invert the signal or increase the amount of current you can use to drive a relay or LED or something. \$\endgroup\$ – Daniel Jun 2 '14 at 23:04

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.