Introduction

A Hall Effect Sensor detects the presence of a magnetic field and varies its output in reaction to it.

In this guide, you will learn to hook up an Analog Hall Effect Sensor with the 100% Arduino compatible development board, Little Bird Uno R3.

Once you've completed this guide, you will understand how to use a hall effect sensor. You could use it to make a speedometer or a burglar alarm!
    • Connect the Hall Effect Sensor to Pin 10

    • Connect the Hall Effect Sensor to 5V.

    • Connect the Hall Effect Sensor to Ground.

    • Insert LED into Breadboard with the Cathode (short leg) on the left hand side.

    • Insert 220 Ohm Resistor into the Breadboard.

    • Ensure that it is inline with the LED's anode (longer leg).

    • Connect the Cathode of the LED to Ground.

    • Connect 220 Ohm Resistor to Digital Pin 13.

  1. int led = 13;//LED pin
    int sensor = 10; //sensor pin
    int val; //numeric variable
    
    void setup()
    {
      pinMode(led, OUTPUT);
      pinMode(sensor, INPUT); //set sensor pin as input
    }
    
    void loop()
    {
      val = digitalRead(sensor); //Read the sensor
      if(val == HIGH) //when magnetic field is detected, turn led on
      {
        digitalWrite(led, HIGH);
      }
      else
      {
        digitalWrite(led, LOW);
      }
    }
    Upload this code to your Arduino.
    When you pass a magnet over the sensor the LED on Pin 13 should turn on. Also a red light switches on the sensor.
    
    • Upload this code to your Arduino.

    • When you pass a magnet over the sensor the LED on Pin 13 should turn on. Also a red light switches on the sensor.