# Designing a circuit to switch leds on when a pre set resistance value is met

#### AshPant

Joined Sep 12, 2019
9
Hi im new to this fourm and to electronics. Im an electrician by trade and enjoy designing electrical circuits but want to learn more about electronics.
I am looking to design a circuit that switches on 3 different leds depending on 3 pre set resistance values.

#### DickCappels

Joined Aug 21, 2008
6,535

A suggestion: put a resistor from a (positive) power supply to the resistance being tested and ground the other end of the resistance being testes. Now you have a voltage that is a function of that resistance. It will be a nonlinear function of the resistance but it is something that you can work with. If it turns out that you need to have the voltage be a linear function of the resistance drive the resistance under test with a constant current source.

Run the voltage from the voltage divider (fixed resistor + resistance under test) to the input of a window comparator and the output of the window comparator will iindicate when the resistance under test is within a narrow window of the resistance for which you are looking.

The two comparators in the circuit can only pull their outputs to ground and resistor RL pulls the output up when both of the outputs are "high". LM393 is a good choice of comparators.

LM393:
http://www.ti.com/product/LM393

Detailed information:
Window Comparator Reference Design - Texas Instruments

#### Attachments

• 42.9 KB Views: 5
• 7.1 KB Views: 3

#### AshPant

Joined Sep 12, 2019
9

A suggestion: put a resistor from a (positive) power supply to the resistance being tested and ground the other end of the resistance being testes. Now you have a voltage that is a function of that resistance. It will be a nonlinear function of the resistance but it is something that you can work with. If it turns out that you need to have the voltage be a linear function of the resistance drive the resistance under test with a constant current source.

Run the voltage from the voltage divider (fixed resistor + resistance under test) to the input of a window comparator and the output of the window comparator will iindicate when the resistance under test is within a narrow window of the resistance for which you are looking.

View attachment 185992

The two comparators in the circuit can only pull their outputs to ground and resistor RL pulls the output up when both of the outputs are "high". LM393 is a good choice of comparators.

LM393:
http://www.ti.com/product/LM393

Detailed information:
Window Comparator Reference Design - Texas Instruments
Thanks for your reply. forgive my ignorance. I think i understand what your saying to do but the why is over my head. Im going to get some parts and start playing around. I dont get much time to play around with this stuff due to my young kids

Joined Mar 10, 2018
4,057
For future designs you might consider getting into the micro game.

Here is your solution put into a micro using mBlock to program it. Its a drag
and drop visual programming language. Several videos on youtube to get
started.

Basically the micro measures the V at the junction of Rx and Rref. If it falls
in a certain range then the LED is turned on. If you want I can post explanation
of the visual block code block by block.

Note mBlock takes your visual code and generates Arduino code, the code that
will be programmed into micro. This code is "C" language like code. Looking at
it can help you at a later time to program in Arduino code which is more comp-
rehensive that mBlock coding. But mBlock can do a lot of designs just using it.

I show this using ATTINY micro, that takes an extra step to get it programmed.
You could use Arduino Nano board, < \$ 3, which can be programmed directly,
to start out simpler. And that same board can be used to program the ATTINY
should you just want to use it. A Nano board looks like this (not actual size) -

Lots of fun, schools are starting out kids with mBlock to program basic robots.
Myself I am working with several visual languages that are like mBlock, all offering
different and same capabilities.

Note you have to worst case the divider, what its range of V will be, with various
Rx and the common Rref. Not difficult, basic V divider just taking into account R tolerances
and micro A/D tolerance when it measures. These values are used in the mBlock
code to test whether an LED should be on or off. Left side circuit shown below.

Note if math seems over whelming just get out your meter, set up divider, and
plug in various Rx's and use that as test V for A/D, then add +/- 10% to those
values for mBlock test block, using 5% or better R's. That should accomplish
same thing roughly as calculations.

The solution -

The lashup -

Note, the value of the R's shown on the proto board not correct, I did not calc
the actual values needed. The LED R's shown, 220 ohms, probably just fine
for actual design.

Because you have a micro here easy to add flashing the LED when it is on.

Regards, Dana.

Last edited:

#### DNA Robotics

Joined Jun 13, 2014
571
Is the resistor like a temperature sensor and you want cold, warm & hot indicators?

Joined Mar 10, 2018
4,057
Here is a possibility -

Ignore its hex, you only need to use 3 of the window comparators.

Feature Description The LMV7231 Hex Window Comparator with 1.5% precision can accurately monitor up to 6 power rails or batteries at one time. The input and output voltages of the device can exceed the supply voltage, V+, of the comparator, and can be up to the maximum ratings listed in the Absolute Maximum Ratings without causing damage or performance degradation. The typical microcontroller input pin with crowbar diode ESD protection circuitry does not allow the input to go above V+, and thus its usefulness is limited in power supply supervision
This would allow you to do DickCappels solution in one chip.

If you go here and filter to "window", "quad", there are other possibilities.

https://www.mouser.com/Semiconductors/Amplifier-ICs/Analog-Comparators/_/N-cib1w?P=1yyv6ooZ1yzvta6

Regards, Dana.

Last edited:

#### eetech00

Joined Jun 8, 2013
1,966
Hi im new to this fourm and to electronics. Im an electrician by trade and enjoy designing electrical circuits but want to learn more about electronics.
I am looking to design a circuit that switches on 3 different leds depending on 3 pre set resistance values.

Hi

Study Ohms law and Kirchoffs law for DC circuits. That will give you a good foundation to understand the info being posted here.
There are some tutorial on the web..

Then start playing with voltage dividers. You’ll then be able to answer your own question.

eT

#### AshPant

Joined Sep 12, 2019
9
Thanks for the replys. I understand how to wire to diagrams but i think i need to do more study on dc laws as posted by eT to understand why
Is the resistor like a temperature sensor and you want cold, warm & hot indicators?
Im trying to make a polarity tester. We use resistor blocks with a different resistance on each cable to prove polarity is correct using an ohm meter between each wire.
Active to earth then active to neutral then earth to neutral. I would like to be able to just plug a 3 pin tester in and do all the tests at once.

#### ci139

Joined Jul 11, 2016
1,680
? one way to succeed only -- requires modding for user interface ...