to automate motor switching on and off
Here is a drawing that shows a water tank with upper and lower float switches that can control a motor via a relay: -



Assume the power is applied with the tank half full. The bottom tank switch is open circuit and the top tank switch is closed. In this situation, the relay gets no power and its contact is open circuit - nothing is activated. 

As the water level falls, eventually the bottom tank switch closes. This provides current to the relay and the relay contact closes. There are two actions now. The motor activates (to fill the tank) and the bottom tank switch is bypassed with the relay contact.

This means the motor pumps water into the tank and continues doing so even though the bottom tank switch has gone open circuit - the relay contact is now bypassing it.

Water continues to fill the tank until the top tank switch goes open circuit. This shuts down the whole circuit and stops the motor. As water is removed from the tank the top tank switch re-closes but the relay will only activate when the bottom tank switch is closed.

The cycle repeats when the tank is nearly empty and the bottom tank switch activates.

Sensors - this idea was for simple float switches but any level detection switch can be used.

EDIT for OP - A relay is an electromechanical device. It uses a coil of wire to create a small electromagnet. The terminals of the coil are shown as a rectangular block in the diagram above. Because the coil is an electromagnet, when current flows it can magnetically attract iron - an iron armature is used inside the relay - the armature has the moving part of the relay contact on it so, when the coil is driven with current, the contact closes. When current is removed from the coil, the contact opens.