Thursday, February 22, 2024

arduino nano – Unable to show menu when Button is pressed (LcdMenu library)


I’m utilizing LcdMenu library to create a Menu system for my undertaking. I need to create a begin display screen to show some Textual content and Sensor Outputs. I adopted this instruction as per the unique developer. I used to be efficiently capable of conceal the menu however was not capable of show it when a button was pressed. Heres the a part of code:

#embody <Arduino.h>
#embody <ItemSubMenu.h>
#embody <ItemInput.h>
#embody <LcdMenu.h>

#outline LCD_ROWS 2
#outline LCD_COLS 16

#outline BUTTON_ENTER 4
#outline BUTTON_UP 2
#outline BUTTON_DOWN 3
#outline BUTTON_SETTING 6
#outline BUTTON_BACK 5

//menu defination

LcdMenu menu(LCD_ROWS, LCD_COLS);

void setup()
{
  Serial.start(9600);
  menu.setupLcdWithMenu(0x20, mainMenu);
  charsetPosition = 0;

  pinMode(BUTTON_ENTER, INPUT_PULLUP);
  pinMode(BUTTON_UP, INPUT_PULLUP);
  pinMode(BUTTON_DOWN, INPUT_PULLUP);
  pinMode(BUTTON_SETTING, INPUT_PULLUP);
  pinMode(BUTTON_BACK, INPUT_PULLUP);

  menu.conceal();
  menu.lcd->setCursor(0, 0);
  menu.lcd->print("Welcome");
  menu.lcd->setCursor(0, 1);
  menu.lcd->print("All");
  delay(2000);
}

void loop()
{
  if (debounce(BUTTON_SETTING))
  {
    menu.present();
  }
  menu.lcd->clear();
  menu.lcd->setCursor(0, 0);
  menu.lcd->print("Voltage: ");
  menu.lcd->print(voltage, 3);
  menu.lcd->print(" V");

  menu.lcd->setCursor(0, 1);
  menu.lcd->print("P: ");
  menu.lcd->print(strain, 2);
  menu.lcd->print(" kPa");
  delay(500);

  //remainder of the buttons defination

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles