Published © Apache-2.0

Hall effect sensor with Arduino

In this project we will use interrupts function of Arduino to detect the magnet near Hall sensor and glow a LED

BeginnerFull instructions provided1 hour12,804
Hall effect sensor with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1
LED (generic)
LED (generic)
×1
hall effect sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit

Code

code

Arduino
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++;
}

Credits

Comments