The Hall Effect Magnetic Sensor can be used for detect the presence (or absence!) of nearby objects such as magnets.
If no magnetic field is present, the signal line of the sensor is HIGH (on digital out). If a magnetic field is presented to the sensor, the signal line goes LOW (on digital out), at the same time the LED (blue) on the sensor lights up.
The distance detection to a magnetic object can be adjusted via the potentiometer on board.
It also has the Analog output, to determine the magnitude of a magnetic field or the distance to a object.
The polarity of the magnetic field is of influence to the switching action. The front side of the sensor needs the opposite polarity as the back of the sensor to switch on.
Connection:
GND = to GND
VCC = to 5V
DO = to any Digital P/O
AO = to any Analog In