Hall Effect Sensor

Hall Effect Sensor for Magnetic Field Detection

Introduction

This experiment demonstrates how to use a Hall Effect sensor to detect magnetic fields with an Arduino.

Hall Effect Sensor

Components Needed

Circuit Setup

  1. Connect the Hall Effect sensor to a digital input pin on the Arduino (e.g., D2).
  2. Connect the LED to one of the digital pins of the Arduino using a 220-ohm resistor in series.

When the Hall sensor detects a magnetic field, the LED will light up.

Hall Effect Circuit Setup

Code for Hall Effect Sensor

Upload the following code to your Arduino to detect magnetic fields:


const int hallPin = 2;
const int ledPin = 13;

void setup() {
  pinMode(hallPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (digitalRead(hallPin) == HIGH) {
    digitalWrite(ledPin, HIGH);  // Turn on LED when magnetic field is detected
  } else {
    digitalWrite(ledPin, LOW);   // Turn off LED when no magnetic field
  }
}
            

Explanation

The Hall Effect sensor detects magnetic fields and sends a signal to the Arduino. If the signal is HIGH, the LED is turned on.

Troubleshooting