fbpx
Arduino Lesson 16: Magnetic Sensor
Arduino Lesson 16

Magnetic Sensor

Use Hall effect sensor to detect magnetic fields

Components Required

Magicbit
Buy
hall effect sensor
Buy

Introduction

Magnetic sensors are able to detect magnetic fields and process this information. The outcome on the position, angle and strength (Hall Effect) or the direction (Magneto Resistive) of an applied magnetic field can be converted into specific output signals.

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).

https://github.com/HarshaWeerasinghe/MagicBit_Sensors/blob/master/resources/hall%20sensor/Screenshot_1.png?raw=true

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

Related Posts
Leave a Reply