Hello, I am using an LCD I2C to measure some voltage and resistance, everything is fine but when I unplug and plug back in the Arduino nano the LCD is not showing up anything. I think some code rules before initializing the LCD thus it make it stuck.
the library I am usingI2C library
#include <Wire.h> //better communication of arduino with I2C devices
#include <LiquidCrystal_I2C.h> //better comunication with lcd
#include <time.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);//stating lcd adress and its characteristics
// Define the input pin for the pulse signal
#define pulse_ip A0
// Declare constants for the switch pin numbers
const int switch1Pin = 5;
const int switch2Pin = 6;
// Declare a variable to store the current function
int function = 0;
void setup() {
delay(2000);
lcd.begin();
lcd.clear();
// Set the input pins for the switches to INPUT mode
pinMode(switch1Pin, INPUT);
pinMode(switch2Pin, INPUT);
pinMode(pulse_ip, INPUT);
// Enable the pull-up resistors for pins 5 and 6
digitalWrite(switch1Pin, HIGH);
digitalWrite(switch2Pin, HIGH);
// Initialize the LCD and clear the screen
}
void loop() {
// Read the states of the switches
int switch1State = digitalRead(switch1Pin);
int switch2State = digitalRead(switch2Pin);
// Check the state of the switches and switch between the functions accordingly
if (switch1State == LOW && switch2State == HIGH) {
// Switch to the next function
function = (function + 1) % 4;
} else if (switch1State == HIGH && switch2State == LOW) {
// Switch to the previous function
function = (function + 3) % 4;
}
// Perform the current function
performCurrentFunction();
}