Interfacing Hall Effect Sensor With Arduino

Introduction: Interfacing Hall Effect Sensor With Arduino

About: hIOTron is an IoT Based company that offers IoT Platforms, IoT Solutions, IoT Training.

In this project, we have used a hall sensor that is able to detect a magnet and also the pole of the magnet.


Hardware Components

Hall Effect Sensor

Arduino Uno

Resistor 10k ohm

Resistor 1k ohm

LED (generic)

Connecting wires

Software Required

Arduino IDE

Step 1: About Project

Hall Effect Sensor:

Few tips about Hall Sensor are as follows: The digital Hall sensor can only recognize if a magnet is present or not (0 or 1) but an analog hall sensor’s output varies depends on the magnetic field around the magnet that is it can recognize how powerful or how distant the magnet is.

This project will direct only at the digital Hall sensors for they are the most usually utilized ones. As per law “when a conductor or semiconductor with current flowing in one direction was organized perpendicular to a magnetic field a voltage could be estimated at right angles to the current path”. With the help of this technique, the hall sensor will be capable to recognize the appearance of the magnet around it.

Arduino Hall Effect Sensor Working

Once we upload the code to the Arduino. We have utilized a 9V battery to power the whole set-up you can utilize any preferable power source. Now take the magnet close to the sensor and your LED will shine and if you get it away it will turn off. What really happens inside is, when we take the magnet close to the sensor modifies its state. This change is sensed by the interrupt pin which will ask the toggle function inside which we change the variable “state” from 0 to 1.

Hence the LED will turn on. Now, when we drive the magnet away from the sensor, again the output of the sensor will develop. This change is again mentioned by our interrupt statement and hence the variable “state” will be modified from 1 to 0. Thus the LED if Turned off. The same repeats every time you take a magnet close to the sensor.

IoT Training will give a thorough view of the Customized IoT Solutions.

Step 2: Run a Program

const byte ledPin = 13; const byte interruptPin = 2; volatile byte state = LOW; int val=0; void setup() { pinMode(ledPin, OUTPUT); pinMode(interruptPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(interruptPin), test, CHANGE); Serial.begin(9600); } void loop() { digitalWrite(ledPin, state); Serial.println(val/2); } void test() { state = !state; val++; }

Be the First to Share


    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Arduino Contest

      Arduino Contest
    • Barbecue Speed Challenge

      Barbecue Speed Challenge