Close
0%
0%

Interfacing Hall Effect Sensor with Arduino

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

Similar projects worth following
86 views
0 followers
There are various sensors available in the market, but we have used a hall sensor magnet in this project which is able to detect a magnet and also the pole of the magnet.

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.

Hall Sensor Effect

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.

  • 1 × Hall Effect Sensor
  • 1 × Arduino UNO & Genuino UNO
  • 1 × Resistor 10k ohm
  • 1 × Resistor 1k ohm
  • 1 × LED (generic)

  • 1
    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++;
    }

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates