Hello guys!! I am new in the forum! Recently I have made a program to control a menu based on Alexander's Brevig menu program! The program is fine thanks to Alexander's code and it worked smoothly until i installed an LCD 16X2 with an I2C attached on it (Yw Robot Arduino LCM1602 IIC V1) to my Arduino Mega with the relevant libraries ( Wire.h and LiquidCrystal_I2C.h V1.2.1) . So the problem is at this point of code :
void menuChanged(MenuChangeEvent changed){
int lastButtonEncoderState = LOW;
int buttonEncoderState = LOW;
MenuItem newMenuItem=changed.to; //get the destination menu
lcd.setCursor(0,1); //set the start position for lcd printing to the second row
if(newMenuItem.getName()==menu.getRoot()){
lcd.print(" START ");
digitalWrite(LED2, HIGH);
}else if(newMenuItem.getName()=="Item1"){
lcd.print(" 100 ");
}else if(newMenuItem.getName()=="Item1SubItem1"){
for (unsigned long time=0; time <= 30000; time++){
digitalWrite(LED, HIGH);
My program does not execute this part of code (Infact it does exicute but instantly. As soon as i start the arduino but without my order.)
So in conclusion :
The right order is 1) Open the Arduino
2) In my LCD appeares "Start"
3) I push the encoder button and then in my lcd appears "100"
This worked fine with my classic lcd until i installed lcd I2C and now the order is :
- Open the Arduino
- Without pushing any button in my lcd appears "100"
Note : When i open the arduino and if i am pushing the encoder button at the time i open the arduino the program starts normally!!
I don't know what to do! Please Help me! Thank you so much for your time!