I try to test this HALL module both digital and analog - no luck at all !
I use the code from the datasheet changed for correct pins - not sure about 13.
No LED is changing when magnet is moved to/from the sensor !
The analog value is changing a little from 1023 most of the time to 1020-1021 when magnet is moved.
The on KY-024 board trim pot. can be turned and turned but nothing happens !
What do I do wrong ?
int led = 13 ; // LED on arduino
int digitalPin = 9; // linear Hall magnetic sensor digital interface
int analogPin = A3; // linear Hall magnetic sensor analog interface
int digitalVal ; // digital readings
int analogVal; // analog readings
void setup ()
{
pinMode (led, OUTPUT);
pinMode (digitalPin, INPUT);
pinMode(analogPin, INPUT);
Serial.begin(9600);
}
void loop ()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin) ;
if (digitalVal == HIGH) // When magnetic field is present, Arduino LED is on
{
digitalWrite (led, HIGH);
}
else
{
digitalWrite (led, LOW);
}
// Read the analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // print analog value
delay(500);
}