#include <LiquidCrystal.h>
int Contrast = 60;
int button1 = 4;
int button2 = 3;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
char hexValues[] = "0123456789ABCDEF"; // Array of hexadecimal values
int currentIndex = 0; // Current index in the array
int lcdPosition = 0; // Current LCD position
void setup() {
pinMode(button1, INPUT);
pinMode(button2, INPUT);
analogWrite(8, Contrast);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Enter Password:");
lcd.setCursor(lcdPosition, 1);
lcd.print(hexValues[currentIndex]);
}
void loop() {
if (digitalRead(button1) == HIGH) {
delay(200); // Debounce the button press
currentIndex = (currentIndex + 1) % 16;
lcd.setCursor(lcdPosition, 1);
lcd.print(hexValues[currentIndex]);
while (digitalRead(button1) == HIGH) {
// Wait for the button to be released
}
}
if (digitalRead(button2) == HIGH) {
delay(200); // Debounce the button press
lcdPosition = (lcdPosition + 1) % 16;
if (lcdPosition == 0) {
lcd.clear(); // Clear the LCD screen only if we're starting from the beginning
lcd.setCursor(0, 0);
lcd.print("Enter Password:");
}
currentIndex = 0; // Reset currentIndex to 0 after button2 is pressed
lcd.setCursor(lcdPosition, 1);
lcd.print(hexValues[currentIndex]);
while (digitalRead(button2) == HIGH) {
// Wait for the button to be released
}
}
}