I have used OH137 hall effect switches successfully in the past using Leo Bodnar boards, making things like non-contact 'gearboxes' for Race sims
I want to know how to use them with Arduinos. I have no specific project in mind, this is simply trying to learn. I have connected one OH137 and an LED in the following way
and have looked on the web for some code and found this
int hallSensorPin = 6;
int ledPin = 2;
int state = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(hallSensorPin, INPUT);
}
void loop(){
state = digitalRead(hallSensorPin);
if (state == LOW) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
Serial.begin(9600);
Serial.println(state);
}
The LED is working fine, but clearly something is up with either the sketch, circuit or both! Even using neodymium magnets I can't get any response from the hall effect sensor
Can anyone advise of how to get the sensor to work with an Arduino?
I tested out the sketch with the hardware yesterday, and it was totally stable, so it looks like the resistors aren't essential, however I may try it again today with the resistor to see if there is any difference. Would the resistor also potentially improve reliability?