SurtrTech
Published © GPL3+

Interfacing Hall Effect sensor with Arduino

Easy way to interface Hall Effect sensor to be used later for proximity sensing, speed measuring and switching

BeginnerProtip1 hour53,981
Interfacing Hall Effect sensor with Arduino

Things used in this project

Story

Read more

Schematics

wiring_1_bb_Yg5YBPWTMq.png

Straight wiring

Code

Hall_Effect_Test.ino

Arduino
Straight test
/* This code is to be used with KY-024 Hall effect sensor
 * It displays both Analog and Digital values given by the sensor
 * Refer to www.surtrtech.com for more details
 */

#define Hall_Sensor A0          //A0 used with analog output, D2 with digital output
#define Hall_Sensor_D 2

int Val1=0,Val2=0;             //Here you can store both values, the Val2 can be boolean


void setup() {
  Serial.begin(9600);
  pinMode(Hall_Sensor_D,INPUT);
 

}

void loop() {
  
   Val1=analogRead(Hall_Sensor);            //We read both values and display them raw on the serial monitor
   Serial.print(Val1);
   Val2=digitalRead(Hall_Sensor_D);
   Serial.print("\t");
   Serial.println(Val2);
}

Credits

SurtrTech

SurtrTech

9 projects • 207 followers
YT Channel bit.ly/35Ai76l, run by Automation and Electrical Engineer, Electronics amateur, no IT background so you may see wreckage in codes

Comments