Magnetic Sensor
Use Hall effect sensor to detect magnetic fields
Components Required
Introduction
Learning outcomes:
- Use Hall Effect sensor to detect magnetic fields.
- Applications of Hall Effect Sensor
Theory
There are actually, two different types of Hall sensors one is Digital Hall sensor and the other is Analog Hall sensor. The digital Hall sensor can only detect if a magnet is present or not (0 or 1) but an analog hall sensor’s output varies based on the magnetic field around the magnet that is it can detect how strong or how far the magnet is. In this project will aim only at the digital Hall sensors for they are the most commonly used ones.
In a Hall Effect sensor, a thin strip of metal has a current applied along it. In the presence of a magnetic field, the electrons in the metal strip are deflected toward one edge, producing a voltage gradient across the short side of the strip (perpendicular to the feed current).
Figure 1: Hall Effect Sensor (Magnetic Sensor)
Methodology
Connect the magnetic sensor to the Magicbit. For this demonstration, we connect the magnetic sensor to D32 pin of the Magicbit. After connect the magnetic sensor to the Magicbit connect it to your pc and upload the code below.
Code
#define MAGNETICsensor 32
void setup() {
Serial.begin(9600);
pinMode(32, INPUT);
}
void loop() {
Serial.println(digitalRead(MAGNETICsensor));
delay(100);
}
Explanation
This Magnetic sensor gives digital outputs. Therefor you can open the serial monitor and see the outputs. ‘1’ for occurred a magnetic field near to the sensor ‘0’ for there is no any considerable magnetic field near by the sensor