The comparator is a very important device, not the least important in electronics. 

How it is shown in the drawings can be seen in the picture below. This radio component has two inputs (inverting and non-inverting) and one output.

Comparators come in the form of microcircuits, which consist of a large number of transistors. 

Sometimes the schematic representation of a comparator looks like the picture below. That is two contacts are added on the sides, which are used for power.

But in this case there may be some confusion. Because this kind of picture is similar to the picture on the schematics of an operational amplifier. 

Principle of operation
The task of this device is to compare the voltages at the inputs. Let’s look at the simplest example of how this works. 

If the voltage applied to the inverting input is higher than the voltage applied to the non-inverting input, the comparator output will be shorted to minus power. 

Please note: if the voltage is higher on the non-inverting input, the comparator output will be shorted to the plus side of the power supply.

What the comparator is used for
Despite their simplicity, comparators have found widespread use in radio electronics. It is safe to say that all the logic circuits used in computing technology rest on their shoulders. 

How to make a light sensor based on a comparator
For this we need a 12 V power supply. Apart from that, we will also need other radio components:

comparator;
a resistor;
a photoresistor;
a variable resistor;
a transistor. 

The 10 kOhm resistor paired with the photoresistor act as a voltage divider which divides the 12 V voltage that the power supply outputs.  

Note: the more light that hits the photoresistor, the higher the voltage on the divider will be.

The voltage from the divider goes to the inverting input of the comparator. And a variable resistor (potentiometer) is connected to the non-inverting input, which also divides the voltage. 

Tips for reading: Installation and connection diagram of a motion sensor: for lighting, with and without a switch

A transistor must be connected to the output of the comparator. It will be open if the voltage at the non-inverting input is higher than at the inverting input. So that’s basically the whole circuit. It is very simple and very clear.