This effect was discovered by Edwin Hall back in 1879 and it is based upon the interaction of magnetic fields with electric ones.
Edwin Hall (from Wikipedia)
In other words, it is a reliable way to activate a switch between two moving parts, without having them to physically touch.
This turns in handy when you need to detect the rotation speed of an object (i.e. a HDD drive disk) and you don't want to have the moving part and the static one touching (which would lead to friction and eventually wear off the contact after some time).
When a magnetic field interacts with an electric field (and it is not parallel to it), electrons are subject to a force (Lorentz Force) that makes them alter their path.
In step 1 an electric field exists in the conductor, electrons move from left to right.
A non parallel (try to visualize it in 3D, ideally perpendicular to the XY plane) a magnetic field generates a Lorentz Force on the electrons.
In step 2 the Lorentz Force pushes the electrons against the upper border of the conductor generating a polarization - / + on the two edges of the conductor.
In step 3 the polarization difference is measured as a voltage perpendicularly to the conductor.
Some commercial devices are available to be used directly as digital switches.
I used some A3144E, which can be easily sourced online at relatively low cost (paid less than 2$ for a set of 10, shipped).
To use them is quite simple, just connect the center pin to GND, the left one (looking at the device you should see the writings on it to make sure you are facing the correct side) to VCC (4.5V up to 28V, it contains a regulator) and the right pin to your digital input.
The output voltage is = Vcc, so be careful if you are planning to use a 3.3V MCU.
A very basic Arduino sketch to test it :
int input_pin = 7;
int led_pin = 13;
void setup()
{
pinMode(led_pin,OUTPUT);
pinMode(input_pin,INPUT_PULLUP);
digitalWrite(led_pin,LOW);
}
void loop()
{
digitalWrite(led_pin,!digitalRead(input_pin));
}
Notice I enable a pullup resistor on the input, just in case to avoid floating signals.
Another thing you should mind is that this sensor is activated by a magnetic field of a specific polarity, the opposite polarity is activated by the opposite side of the same sensor, make sure you place you magnet correctly.
The reason why I am testing these sensors is to identify a ZERO point for a stepping motor.
Let me explain better : I will mount a ultrasound sensor on top of a stepping motor, this will enable a fine scanning of the area.
However unfortunately stepping motors do not record or detect their position, so if the sensor is all the way to the left, in the middle or half way to the right, only the software, counting the steps, can tell.
Unfortunately if you reset your MCU the sensor will remain in whatever position it was before the reset and the step count will start from zero.
So, when booting the MCU I could move the stepping motor until a tiny magnet reaches a hall effect sensor.
Depending on the size of the magnet we can calculate how many steps we will need to clear it, thus we can calculate the mid point giving us a reliable zero reading.
I will probably use two sensors, static and a rotating neodymium magnet (will rotate together with the ultrasound sensor), meaning I will need to travel 180 degrees maximum before hitting one of the two sensors and being able to calculate the exact position.
Hopefully I will be able to show details of the construction once I present the ultrasound scanner, provided I will finally implement it that way :)