A comparator is better. It's operates faster and is simpler to wire up and work with if you are using discrete components. You can do what you describe very simply with just comparators and no MCU. You just drive the LEDs directly with the comparator output (and current limiting resistor), or use the comparator output to control a transistor switch that drives the LED (and current limiting resistor).
THe only advantage in using an ADC for this is that:
1. If you need the MCU to do other things and the MCU has an ADC built-in that you can spare but no built-in comparator. It's already there, you might as well use it rather than adding on a discrete comparator.
2. If you need to be able to variable threshold voltage, but this can also be done with comparators too...it's just a little bit messier if you are using discrete components since you need to add in a DAC for the voltage reference and the interface with the MCU. But some MCUs with built-in comparators also have built-in DACs to serve as a variable voltage reference for their comparators so in this case, the comparator is still better than the DAC.
3. You have way too many levels you have to measure. You need one comparator for every level you want to measure, whereas one ADC can measure many different levels.
...if he needs the MCU to be doing other things. If this is the only task of the MCU he should just use comparators and drop the MCU. YOu don't need MCUs for this task.
The problem with using the comparator is that there is only one and three voltages (levels) to monitor. With the ADC you can just let it run, go off and do something else and when you return it's got the reading ready.
It's not actually clear what Suraj wants,
Is it,
less than 3V =red
3V to 4V = yellow
greater than 4V = green
The problem with using the comparator is that there is only one and three voltages (levels) to monitor. With the ADC you can just let it run, go off and do something else and when you return it's got the reading ready.
It's not actually clear what Suraj wants,
Is it,
less than 3V =red
3V to 4V = yellow
greater than 4V = green
Ah, yeah, if only one LED is going to be on for each voltage range, then an internal ADC is much more convenient.
With comparators you would either need 2 comparators for each voltage range you want to detect since you now need to know if the voltage is between two thresholds, rather than just above or below one threshold. Or if you used one comparator per voltage threshold you would need either code or logic gates to interpret the output of the comparators for the voltage range. Either way, probably more work than just using an ADC.