I created this code
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
int hallSensorPin = 2;
int ledPin = 3;
int state = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(hallSensorPin, INPUT);
}
void loop(){
state = digitalRead(hallSensorPin);
if (state == LOW) {
lcd.setCursor(0,1);
lcd.print("ON");
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
lcd.setCursor(0,1);
lcd.print("OFF");
}
}
However, for some reason, my hall effect sensor is flickering on and off. Is there any way to adjust my code to reduce sensitivity? Thanks so much.
Once I figure it out ,I'll be able to learn rpm detection.