LCD User Input


I am currently figuring out the best way to have user input without the use a of a number pad. Right now I am creating arrays in software that are sent to the LCD as options that the user can select from. (Scrolling up or down with two buttons, then selecting with another button)

Ex: array of numbers 1-16 for the user to choose. If the user chooses the number 5 this is sent to the Arduino and then to a sensor setpoint.

Is this feasible? What might this look like in code?


I did a similar interface for a previous project. Just create an array of menus, which are themselves just arrays of strings. Then store the selected menu, which will be displayed differently in the lcd update. That way I could make nested menus, and additionally use left/right buttons or a rotary encoder to adjust an value.

const int NUM_MENUS = 2;
char *menus[][] = {
  { // Main menu
    "Exit", 0
  { // Settings
    "Back", 0
byte active_menu = 0;
byte selected_option[NUM_MENUS];

void loop() {
  // move selected_option up and down
  if (digitalRead(BUTTON_UP)   == LOW && selected_option[active_menu] > 0) {
  if (digitalRead(BUTTON_DOWN) == LOW && selected_option[active_menu] < NUM_MENUS-1) {
  // jump to next menu
  if (digitalRead(BUTTON_OK) == LOW) {
    int opt = active_menu * 100 + selected_option[active_menu]; // encode options in a single variable
    switch (opt) {
    case 000: // menu 0 option 0 : "play"
       // do something
    case 002: // menu 0 option 2 : "settings"
       active_menu = 1; // jump active_menu to menu 1 = settings
    case 100: // menu 1 option 0 : "volume"
       // do something with volume
    case 102: // menu 1 option 2 : "back"
       active_menu = 0; // jump back to active_menu 0 = main menu


void update_lcd() {
  // assuming a 6x8 font and that lcd can show only five lines (128x60)
  char *menu[] = menus[active_menu];
  int selected = selected_option[active_menu];
  // we will print on the screen just the options near the selected one
  int first = max(0, selected-2);
  int last = min(NUM_MENUS-1, selected+2), 
  int y = 0;
  for (int i=first; i<=last && menu[i] != NULL; i++) {
    if (i == selected) {
      lcd.drawStr(0, y, "->"); // print an arrow near the selected option
    lcd.drawStr(16, y, menu[i]); // print all menu options in the lcd screen
    y += 8; // advance to next text line

Ex: array of numbers 1-16 for the user to choose. If the user chooses the number 5

How does the user choose the number 5? Explain the EXACT steps that have to happen.

Then, you'll see that "this is sent to the Arduino" doesn't make sense. The Arduino has to be responsible for making the "selection" happen, so it already knows what was "selected". Now, making the number 5 out of what was "selected" might be a different story. If the user "selected" "Five", making a number out of that is going to be a challenge.