#include <LiquidCrystal.h>
// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Define potentiometer pin
const int contrastPin = A0; // Connect potentiometer to analog pin A0
void setup() {
// Set up the number of columns and rows on the LCD
lcd.begin(16, 2); // Adjust this according to your LCD's specifications (columns, rows)
}
void loop() {
// Read the value from the potentiometer
int contrastValue = analogRead(contrastPin);
// Adjust the contrast of the LCD based on potentiometer value
lcd.setCursor(0, 0);
lcd.print("hello, world!");
lcd.setCursor(0, 1);
lcd.print("Contrast: ");
// Display the potentiometer value as a bar graph for contrast adjustment
int numBlocks = map(contrastValue, 0, 1023, 0, 16); // Map potentiometer value to 16 blocks
for (int i = 0; i < numBlocks; i++) {
lcd.print("#");
}
delay(100); // Adjust this delay as needed for responsiveness
}