#include < Wire.h >
#include < LiquidCrystal_I2C.h >
#define HALL_SENSOR_PIN 2 // Digital pin connected to the Hall sensor
#define MAGNET_DISTANCE 10 // Distance between magnets in cm
LiquidCrystal_I2C lcd(0x3F, 16, 2); // Set the I2C address and LCD dimensions
volatile unsigned long pulseCount = 0;
unsigned long lastTime = 0;
float speed = 0.0;
float distance = 0.0;
void setup()
{
pinMode(HALL_SENSOR_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(HALL_SENSOR_PIN), countPulses, FALLING);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Speed: ");
lcd.setCursor(0, 1);
lcd.print("Distance: ");
}
void loop()
{
unsigned long currentTime = millis();
if (currentTime - lastTime >= 1000) // Update every second