What are comparators?
There are google and wiki. 8)
In short comparators are device to compare
Two types digital and analogue.
- Digital two groups of four bits input. When the binary value is the same on both the equals output goes high. There is also a greater than and less than output, these can be cascaded to any width you want.
- Analogie or voltage comparator, two inputs if the + one is higher than the - one the output is high otherwise it is low.
Like Grumpy_Mike said. The digital type and the analogue type. I don't know what type you want to know, but if you mean analogue... Well it basically two Voltage divider and one op-amp.
Here is example: +5 V -- 10 K ---to "plus" side of op-amp ---- 10 K -- GND <--- V1 is 2.5 V
+5 V -- 47 K --- to "minus" side of op-amp --- 10 K --- GND <--- V2 is 0.877 V
The op-amp output will be a HIGH or + 5 V <--- hope I am right.
Use a LM339 <----- It will work. BUT do not use the following... LM741, LF071, LF072, LM1458 ... they did not works. I try. My raison is they need dual power ( plus / GND / minus ). The LM339 do not need dual power only one. ( plus / GND )
Analogue comparator are usefull if you need two state ( HIGH or LOW )
Above is the internal circuit of the LM339. I want to compare 2 inputs, I will put the Higher Voltage on +Input 1 and the Lower Voltage on -Input 1. Do I need to connect VCC and Ground to 5V and GND from the Arduino? The Output 1 will be HIGH, right?
Do I need to connect VCC and Ground to 5V and GND from the Arduino?
Yes.
The Output 1 will be HIGH, right?
Yes BUT this has an open collector output, that means you have to have a pull up resistor from the output to the +5. This can either be a real resistor (about 3K3) or the internal pull resistors in the arduino. (enable them with a digitalWrite HIGH once you have defined the pin as an input)