LM339 Quad Comparator
Voltage comparators are very useful components that does just what the name tells you: it compares voltages (duh!). A voltage comparator can be seen as a specialised op-amp but you really don’t need to know that – but op-amps are great components! What you do need to know is that a comparator works by feeding it two voltages A and B and it will then tell you on a third pin if A is greater than B or the other way around – output is digital.
What can you use this thing for then? Well a simple application is when you have some variable resistor (for example a light dependent resistor) that you check against a reference threshold variable in software (e.g. IF a < 100 then …). This comparison can now be made in hardware via the comparator and you no longer need to use an analogue pin for that. The reference threshold can be made through a potential divider with one constant and one variable resistor if you would like to be able to adjust the threshold.
The LM339 chip is actually four comparators in one chip and you could for example use this to build a line follower based on digital inputs with four sensors.