I have a car HVAC daughter board that set a pin to a specific voltage depending on which of the 6 physical buttons is pushed. I don't have any schematics neither datasheet. I measured voltage of this pin when each button is pushed. I have then 6 values.

I would like to turn on one LED only when my input is between a given range (for better accuracy even then I measured a specific voltage for each button). So I have my 5 V rail, and an input that I want to use to drive 6 LEDs.

I want this input to light on :
LED1 only when 3.08V > input > 2.88V
LED2 only when 2.76V > input > 2.56V
LED3 only when 2.34V > input > 2.14V
LED4 only when 1.75V > input > 1.55V
LED5 only when 1.01V > input > 0.81V
LED6 only when input < 0.5

Basically, I want to make something fancy, light up one led at time for a specific button pushed on a daughter board.

I read those two topics that gave me hints:

I understood that I will probably have to use window comparators like the LM339B but I have no idea how.

Would you please explain the simplest way to achieve this? If you can provide a schematic, I would appreciate it.

  • \$\begingroup\$ Windows regulator? \$\endgroup\$ Commented May 4, 2023 at 21:49
  • 3
    \$\begingroup\$ Sounds like a job for a single small MCU with analog input instead of handful of comparator ICs. \$\endgroup\$
    – Justme
    Commented May 4, 2023 at 21:52
  • \$\begingroup\$ Martin.G - Hi, There are gaps in the voltage ranges for the various LED lighting voltages which you list. For example, what do you want to happen for an input of 1.2 V, which is not in any of the ranges which you list? (Same applies to all the other gaps.) Also, have you already researched possible solutions and eliminated them? If so, what have you already considered, but decided was not suitable, and why? Thanks. (It seems that you haven't read the site tour, so please see the tour & help center for the main site rules.) \$\endgroup\$
    – SamGibson
    Commented May 4, 2023 at 21:58
  • 1
    \$\begingroup\$ Any of the Arduino series of development boards would do this and should give you a useful but easy learning experience at very low cost. There are endless resources available to guide you in attaching the LEDs and writing the code. There's even arduino.stackexchange.com. \$\endgroup\$
    – Transistor
    Commented May 4, 2023 at 22:13
  • 3
    \$\begingroup\$ Martin, using comparators will require two per window and one for the < 0.5 V, so eleven in total. You'll also need a precision resistor chain with at least 12 resistors. We're at 23 components already - without considering voltage regulation and decoupling capacitors - and a bundle of trouble wiring up and calibrating. The Arduino approach will require one component (the Arduino module) and a USB cable. The Nano will be much smaller than anything you'll be able to hand solder. \$\endgroup\$
    – Transistor
    Commented May 4, 2023 at 22:28

1 Answer 1


Here is a straightforward approach, note that the resistor values interact with each other. I have chosen a current of 1mA for the resistor chain so that the values are easily calculated by typing your numbers into a spreadsheet to find the differences from the previous voltage. It takes 12 resistors (not all the values are available as standard precision resistors so you might double up on some to get closer), a trimpot to compensate for inaccuracy in the 5V supply and 6 more resistors for the LEDs. Plus 3 quad comparator chips.

Personally, I would take the MCU (or Arduino) approach since it is so much easier to change the values and the inaccuracies are less of a concern (I have not covered the sources of error in an analog circuit such as this- after the reference error is trimmed out they are primarily resistor value errors (cumulative), offset voltage errors and a bit of error due to bias currents.

enter image description here

Aside from the divider chain, it's really the same simple circuit repeated 5 times, plus a comparator for the initial LED. In practice you would sprinkle a few 100nF caps across the supply pins of the chips for bypassing.

As you can see, it works fine:

enter image description here

  • \$\begingroup\$ Thanks a lot !! Would you link the LTSpice file to adjust it to my needs if needed ? \$\endgroup\$
    – Balobiana
    Commented May 5, 2023 at 9:59

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.