Hi everyone,
i am trying to read analog values of 3144 hall effect sensor and then use these values to control different LEDs. But the problem is the analog values i am getting aren't constant they keep on varying even if i place the sensor&magnet at a stationary position.
//
float hallpin1 = A0;
float hallpin2 = A0;
float hallpin3 = A2;
float hallpin4 = A3;
float hallState1; // variable for reading the hall sensor status
float hallState2;
float hallState3;
float hallState4;
void setup() {
Serial.begin(9600);
// the number of the hall effect sensor pin
const int ledPin = 13; // the number of the LED pin
//// variables will change:
//
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the hall effect sensor pin as an input:
pinMode(hallpin1, INPUT);
pinMode(hallpin2, INPUT);
pinMode(hallpin3, INPUT);
pinMode(hallpin4, INPUT);
}
void loop(){
// read the state of the hall effect sensor:
hallState1 = analogRead(hallpin1);
Serial.print("Hallstate1 = ");
Serial.println(hallState1);
delay(300);
hallState2 = analogRead(hallpin2);
Serial.print("Hallstate2 = ");
Serial.println(hallState2);
delay(300);
hallState3 = analogRead(hallpin3);
Serial.print("Hallstate3 = ");
Serial.println(hallState3);
delay(300);
hallState4 = analogRead(hallpin4);
Serial.print("Hallstate4 = ");
Serial.println(hallState4);
delay(300);
}