I have basic undestanding of electronics, but I never build anything more then simple one element logic boards. I know how transistor, resistors, and LEDs works, but I having trouble figuring out proper specs for each one. Here at home, I'm trying to build simple IR detector with 2 indicator LEDs, it suppose to lid one of red or green if object inside IR detector.

Here is principal schematics attached. IR led (D3) connected with photodiode (PD2), signal from photodiode go to transistor (B139_2) base and which suppose to get open and allow red LED to lid, same signal go to second transistor (BD139_3) base and close it (reversed using lowering resistor), leads to off green LED. And wise-verse to open red and close green.

How to find proper values for transistor (model) and resistor values to make schematics works?

Photodiode BL-L3522PD working on 5V gives output 0.35V when lid, then I need to find proper transistor which opens on 0.35V. And I guess should keep in mind all internal resistance of all elements, like LEDS and transistors. I suppose transistor has to be MOSFET sine I'm not using current to control transistor, but only voltage.

principal schematics

Second attempt.

Almost working. If I connect 5V to the BC547 base it switch the LED's (green / red) just fine. But, for some reason, If I connect PD2 to the BC547 base it turn's the green LED and RED at the same time. Still the same question: how to find correct transistors (not by guessing or googling for similar schematics), and how to get correct resistor values. (I already blew up one transistor, so, be save, it actually blow, ohh!)

EDIT: D3 goes with 220ohm resistor. replacing PD1 with L-7113P3C makes this schematics works. Check youtube link below.

enter image description here

Third attempt.

Using phototransistor L-7113P3C. Using two BC547 transistor's in pair to switch red and green led's.

enter image description here

  • \$\begingroup\$ First thing to improve: D1, D2 and D3 each need an own resistor for current control. \$\endgroup\$ Oct 28, 2019 at 9:42
  • \$\begingroup\$ Just a tip: ground symbols should always point towards "the ground" (downwards). The symbol represents conducting plates buried in the earth. \$\endgroup\$
    – Transistor
    Oct 28, 2019 at 10:14
  • \$\begingroup\$ A photodiode's voltage isn't what you want to consider, but instead the current it can produce/permit when exposed to light. So you don't need to arrange things the way you have. In fact, you probably shouldn't. You don't say, but how much current flows through the photodiode when exposed to your light source? Try using a voltage source and resistor in series the photodiode (arranged in opposition.) Then measure the voltage drop across your known resistor as you change the lighting circumstances. Let us know what you get for "no light" and "light" situations. \$\endgroup\$
    – jonk
    Oct 28, 2019 at 17:13
  • \$\begingroup\$ You are still leaving out the resistors needed to control the current in the active devices. D3 is dead at this point and PD1 is responding to the light in the room. \$\endgroup\$
    – EinarA
    Nov 5, 2019 at 22:04

3 Answers 3


I have drawn a schematic for a simple circuit that will do what you want. When enough light shines on the photo diode, PD1, Q1 turns on enough to hold Q2 off and current flows through R5, D2 to light up LED2. When light is blocked from reaching PD1 , Q1 will turn off, and current from R4 will turn on Q2, sending the current from R5 in to LED1. Since photo diodes produce some current even when not fully illuminated, R3 must be adjusted to make Q1 turn off. R1 and R2 limit the current in their respective diodes.enter image description here I have assumed that PD1 only produces a few microamps. If it is more like 100 uA, it can be put in the place of Q1 and R2,3 can be omitted. It is usually necessary to shield the photo diode from ambient light; a short peice of black tubing slipped over the diode is the easiest method. Transistors are any general purpose type: 3904, 2222, BC547, etc.

  • \$\begingroup\$ Best solution so far! Still no recommended transistors and explanation how exactly does it works (what voltage, which resistors and values come from, hacking is cool, but understanding is nice). I found BC547 (npn) works great with BC557 (pnp). Let's keep digging for best solution, I will share mine when I finish hacking it!. \$\endgroup\$ Nov 5, 2019 at 19:45
  • \$\begingroup\$ Transistors are any general purpose type: 3904, 2222, BC547, etc. Asking for an explanation of all the design decisions involved in even a simple circuit like this is asking me to write a whole book and is not reasonable. I'm afraid your ' hacking ' will be more literal than figurative; it works correctly as shown. \$\endgroup\$
    – EinarA
    Nov 5, 2019 at 20:19
  • \$\begingroup\$ One question then, why did you connect PD1 to the "+" instead of ground? \$\endgroup\$ Nov 5, 2019 at 20:21
  • \$\begingroup\$ Light shining on a photo diode causes current to flow and this current is opposite to the normal forward direction. \$\endgroup\$
    – EinarA
    Nov 5, 2019 at 20:35
  • 1
    \$\begingroup\$ My comment just above was meant for Damien. I also found that the diode I hoped to use didn't produce enough current so I switched to a photo transistor which I got from a VCR. I reduced R3 to 1K and R2 to 3.9K. After I slipped a piece of black tubing over the photo transistor and pointed it at the IR LED, the output would switch color when I put my hand in the way. \$\endgroup\$
    – EinarA
    Nov 8, 2019 at 6:32

Your schematic has several issues.

Current needs to be limited in the LEDs, PD2 probably won't be able to drive the BJT and would be very dependent on temperature.

Generally speaking, if you want to convert an analog signal (Your photodiode) to a digital "on/off" signal, the safe choice is to use an operational amplifier in comparator mode.

Op-amp is now perhaps the most widely used circuit in all analog systems and has replaced most discrete circuitry.

Using an opamp as a comparator, you can have a trim pot that you can adjust for the level of detection.

Here is a circuit that would achieve your needs.


simulate this circuit – Schematic created using CircuitLab

D2 is your IR LED, D1 your photodiode. A voltage is generated between D1 and R1 which is relative the light received. R3 allows you to adjust the threshold upon which D3 would light up.

[Edit for on/off LEDs as DKNguyen & Dorian mentionned]

  • \$\begingroup\$ Thanks! But I'm using two output LED's! Whole idea is to use two, not one. And I need good transistor database with full specs where I can find one, which can trigger on .35V \$\endgroup\$ Oct 31, 2019 at 16:11
  • 2
    \$\begingroup\$ @AlexeyKuznetsov That's an issue with your design, not the transistor. You made your design require transistors made of exotic materials for a mundane application. Re-design it so it doesn't. Amplify your photodiode firs or use a phototransistor. \$\endgroup\$
    – DKNguyen
    Oct 31, 2019 at 17:26
  • \$\begingroup\$ @DKNguyen ok, ok. I'm learning. Keep booth questions then. What the best way to go? Which model of opamp should I use? How to enable two output LED's? How low transistors threshold voltage can go, is here a transistor database where I can see how many low voltage transistors available? I found BSH103, works on 0.4V... any lower? \$\endgroup\$ Nov 2, 2019 at 13:24
  • \$\begingroup\$ @AlexeyKuznetsov Transistor thresholds can get pretty low like germanium, I think, but those are expensive, obsolete, or rare and used for things like RF which is why you don't use them unless your application is so low power and noise sensitive that you don't have any other choice. Some ideas for your ORIGINAL circuit: (1) swap out the photodiode for a phototransistor which automatically has more gain (2) build a transimpedance amplifier around the photodiode in your original circuit. For DAMIEN's circuit: you can use the op-amp (or comparator) to drive transistors to drive two LEDs opposite \$\endgroup\$
    – DKNguyen
    Nov 2, 2019 at 17:54
  • \$\begingroup\$ Note that in Damien's circuit, the component specified is an op-amp, but it is being used without negative feedback(nothing going from output to the -input) which makes it behave as an unoptimized comparator. A real comparator is similar but is optimized to be fast and in not concerned about being very linear in the intermediate region between full HI and full LO (which is the opposite of an op-amp). That means you would ideally use a comparator instead. For your case it is unlikely to matter though. \$\endgroup\$
    – DKNguyen
    Nov 2, 2019 at 17:57

LEDs MUST be current limited.
Connect D1 & D2 upper (Anode) directly to V1.
Add a 1k resistor in series with each of D1 and D2.

Consider adding a 10K pot from V1 to ground with pot wiper to Cathode (now grounded) of detector. Pot can be adjusted to alter "sensitivity".


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.