// Include the necessary libraries
#include <Wire.h>
#include <LiquidCrystal.h>
// Initialize the LiquidCrystal library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
// Define the pin connected to the potentiometer
int potPin = A0;
// Variable to store the value read from the potentiometer
int potValue = 0;
void setup() {
// Set up the LCD's number of columns and rows
lcd.begin(16, 2);
// Print a message to the LCD
lcd.print("Heart Rate:");
// Wait for 2 seconds
delay(2000);
}
void loop() {
// Clear the LCD screen
lcd.clear();
// Initialize an empty string for the message
String message = "";
// Read the value from the potentiometer and divide by 10
potValue = analogRead(potPin) / 10;
// Check the potentiometer value and set the appropriate message
if (potValue <= 30) {
message = " - TOO LOW";
} else if (potValue > 30 && potValue <= 70) {
message = " - NORMAL";
} else {
message = " - TOO HIGH";
}
// Set the cursor to column 0, line 2
lcd.setCursor(0, 2);
// Print the potentiometer value and the message to the LCD
lcd.print(potValue + message);
// Wait for 100 milliseconds
delay(100);
}