I have a microcontroller which has an analog output which I can set anywhere between 0V and 3.3V. I use this to drive one side of a TL072, configured as a voltage follower. The microcontroller and the TL072 currently share a common 0V. The TL072's output drives an LED which illuminates an LDR which its part of an audio circuit. The LED can be set anywhere from completely dark (or as close as possible), to fully lit (or as close as possible). I've designed the circuit to include a voltage follower because I think the current draw of the LED might be too large for the microcontroller. In the diagram below, the microcontroller uses GND as its ground, and 5V as its supply.

schematic with common ground

When the microcontroller's analog out is close to 0V, the output from the TL072 swings up to the +ve supply voltage. The datasheet for the TL072 tells me that it's not rail-to-rail, and so I understand that this swing to the supply voltage is expected. But it is a problem.

Therefore, I'd like to give the microcontroller and the LED a different ground reference, perhaps around 2V, so that the analog out's 0V isn't close to the 0V rail of the TL072. I'm wondering if I can use the other side of my TL072 to provide a virtual ground, as in the diagram below. In this schematic, the microcontroller uses the virtual ground as its ground, and vGnd+5V as its supply.

schematic with virtual ground

Is this workable? Is there a better approach?

  • 1
    \$\begingroup\$ The LED being grounded or not doesn't matter; it's the TL072's power rails (pins 4 and 8) that matter. Also, you need a resistor in series with your LED. There are easier ways to do what you want than an op amp follower. \$\endgroup\$
    – Hearth
    Commented Sep 19, 2023 at 12:06
  • 1
    \$\begingroup\$ Have you considered a different opamp or a charge pump or similar to generate a negative voltage rail to enable you to use almost any opamp? \$\endgroup\$
    – winny
    Commented Sep 19, 2023 at 12:07
  • 1
    \$\begingroup\$ Opamps like to seem like they can be powered from Vcc and Gnd, but really 98% of them would prefer their "ground" to be a negative voltage. Even "rail-to-rail" opamps cannot work exactly to their rail voltages. \$\endgroup\$
    – rdtsc
    Commented Sep 19, 2023 at 12:26
  • 3
    \$\begingroup\$ Been bitten with what I suspect is a phase-inversion problem when using TL07x opamps - similar to what you describe. To be fair, you're operating outside common-mode range limits, so anything (bad) can happen. Either add a -ve power rail, or substitute another opamp that supports rail-to-rail input topology. \$\endgroup\$
    – glen_geek
    Commented Sep 19, 2023 at 12:56
  • 2
    \$\begingroup\$ @OutstandingBill Is that true analog out? I know the Arduino's "analog out" is PWM. Either way, that's still a bad way to drive an LED. Always use a resistor for LEDs, unless you have an actual constant-current drive. \$\endgroup\$
    – Hearth
    Commented Sep 20, 2023 at 0:32

2 Answers 2


The TL072 is a good opamp for many purposes, but not so good for this one.

Its worst-case common mode range is within about +/- 4 volts of either supply rail. That would give you a 1 volt input operating range with a single 9 V supply. In practice, a given sample may be better or even much better than that. But, may not.

A far easier alternative would be to use an ancient low-cost time-honoured LM358 (dual) or LM324 (quad) opamp. These are essentially negative rail to Vdd-about 3 V on input.
Outputs are "close enough to rail-to-rail" for this task.
An LM358 will source 20 mA minimum and 40 mA typical at 15 V supply. At 9 V it will source enough to light any sensible indicator LED.
Current sinking capability is about 50% of sourcing capability.

The LED is part of an audio circuit, so any additional components would need to be fairly quiet.

That needs more explanation (in the question).
Is the LED an indicator in a circuit handling audio, but uninvolved with the actual audio signal? Or actively part of the audio signal path in some way?
In the former case, an LM358 would be suitable; in the latter case it may be.

An easy and cheap solution is to use a resistor and an NPN "jellybean" transistor as an emitter-follower current source:

  • Analogue signal to transistor base.
  • LED from emitter via suitable resistor to ground.
  • Collector to positive supply.

Possibly best of all

This circuit implements an analog controlled current source.
I_LED is proportional to V_R2 as V_R2 = I_R2 x 2.
The analog input is scaled down by R3 and R4 and the opamp then drives Q1 so that V_R2 and so also I_LED tracks the analogue voltage.

Unlike your approaches, you do not have to cope with the non-linear voltage-current relationship of the LED. Here, you set the LED current as desired. Q1 can be just about any small NPN transistor. (I'd use a BC337 or SMD equivalent. Others would choose otherwise).

R5 is for protection only and could be omitted - it sets the maximum LED current if the transistor is driven hard on.


simulate this circuit – Schematic created using CircuitLab

  • 1
    \$\begingroup\$ Another concern might be the current sourcing and sinking capabilities. \$\endgroup\$ Commented Sep 19, 2023 at 12:42
  • 1
    \$\begingroup\$ @ScottSeidman Thanks. Added comment on LM358 current sourcing. \$\endgroup\$
    – Russell McMahon
    Commented Sep 19, 2023 at 12:47
  • \$\begingroup\$ @RussellMcMahon, thank you. I've added some explanation to the question. Would the LM358 approach be suitable, then? I think I understand it better than the jellybean approach. \$\endgroup\$ Commented Sep 19, 2023 at 13:00
  • 2
    \$\begingroup\$ @OutstandingBill I've amended my basic transistor solution BUT the added opamp and transistor solution provides a far better result if you want to vary LED current in a very controlled manner. The KM358 is about as cheap an opamp as you can get and ANY small NPN transistor will work \$\endgroup\$
    – Russell McMahon
    Commented Sep 19, 2023 at 13:23
  • \$\begingroup\$ @RussellMcMahon Would a small stabilization capacitor make sense? Output to (-) input, I mean. \$\endgroup\$ Commented Sep 19, 2023 at 14:11

Russel McMahon's suggestion for an op-amp substitute that accommodates the required +0 to +3V input range is good. Any rail-to-rail opamp that accepts a +9V DC supply would also be appropriate, so long as it can output sufficient LED current.

LM358 can source 20 mA at room temperature, but this drops to 10mA over the full temperature range. 10mA should be enough to excite a modern efficient LED. For exciting LDR (light-dependent-resistor), an efficient green LED might be best. Short-circuit current of this opamp is +/- 40mA.

A drive circuit that translates input voltage to LED current in a linear way is shown below. For most LEDs, illumination is directly proportional to LED current (to a 1st-order approximation). R1 has been chosen to give LED current of 10mA when \$V_{in}= +3V\$:


simulate this circuit – Schematic created using CircuitLab

  • 1
    \$\begingroup\$ Very nice - you saved my transistor, if the opamp is capable of whatever current he wants - which it probably is. The LM358 is specd at 20 mA source min at 15V supply. At 9V that will be lower but should be very adequate. || He could even operate it on 3V3 (just) with Vcommon ode then about 0-1.8V. Isource getting "rather low" :-) . \$\endgroup\$
    – Russell McMahon
    Commented Sep 19, 2023 at 13:28
  • \$\begingroup\$ @RussellMcMahon These notes on OnSemi's datasheet only specify minimums for sourcing and sinking over \$0^\circ\:\text{C}\le T\le 70^\circ\:\text{C}\$ for the LM358A, specifically. (I guess other variations don't get any guarantee.) That's at Vcc=5 V. That temperature range is relatively modest, too. Wouldn't a conservative design hold short at 10 mA sourcing, even considering 9 V instead of 5 V? Just to be sure? \$\endgroup\$ Commented Sep 19, 2023 at 13:55
  • \$\begingroup\$ @periblepsis I used only one data sheet. In specific cases a DS matching the IC in use may be in order BUT I think the LM358 is so well standardised by now that they are all very similar ||. The datasheet that you cite says Vcc=5V (at the top) unless specified, but the Source currents are all at Vcc=15V. 20 mA min. 40 mA typ. That's solely at 25C - so different at extremes. In this case a modern LED at 5 mA will typically give a lumen os so, so very bright if used as an indicator. \$\endgroup\$
    – Russell McMahon
    Commented Sep 19, 2023 at 14:10
  • \$\begingroup\$ @RussellMcMahon Since it appears this is used with an LDR, I'd imagine that even 5 mA as the design maximum should be fine, as whatever is on the other side of the LDR can be designed for that. Thanks. \$\endgroup\$ Commented Sep 19, 2023 at 14:13

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.