LCD keypad menu help

Hi everyone
I am looking for some help trying to understand the code used in examples provided by nuelectronics with there LCD keypad shield.

Here's the code I have:

 int adc_key_val[5] ={30, 150, 360, 535, 760 };

int NUM_KEYS = 5;

....

void loop() 

{ adc_key_in = analogRead(0); // read the value from the

sensor digitalWrite(13, HIGH); 

key = get_key(adc_key_in); // convert into key press 

if (key != oldkey) // if keypress is detected {

delay(50); // wait for debounce time 

adc_key_in = analogRead(0); //read the value from the sensor

key = get_key(adc_key_in); // convert into key press

 if (key != oldkey) { 

oldkey = key; 

if (key >=0){

lcd.cursorTo(2, 0); //line=2, x=0 

lcd.printIn(msgs[key]); 

} 

} 

}

digitalWrite(13, LOW); }

I am trying to make a menu that uses the left and right to select a category and the up and down to select the option. When the option you want is on the screen you then hit the select key to preform the action.

I am a complete noob at this and I am not looking for someone to do my work for me. I really want to understand how this works.
I cant find any info when searching. I think what's confusing me is that I can't just identify a pin because the board uses a voltage divider to output all 5 pins to the 1 AD0 pin.

Does that mean that the values listed here int adc_key_val[5] ={30, 150, 360, 535, 760 }; are my reference numbers per button?

My first goal is turning a LED on and off via the menu :smiley:

PS: I do learn fast by examples if anyone can find example code that I missed somewhere

Hello,

I'm playing with the LCD Keypad Shield, too.

I've modified it in the first step like this:

On top I've added some defines, like this:

on top of my program/sketch I've putted some define statements

#define rightKey    0
#define upKey       1
#define downKey     2
#define leftKey     3
#define selectKey   4
#define NUM_KEYS    5

the main loop I've done like this:

void loop() 
{
    int key = 0;
    adc_key_in = analogRead(0);                  // read the value from the sensor  
    key = get_key(adc_key_in);                  // convert into key press
    if (key != oldkey)                        // if keypress is detected
    {
        delay(50);                        // wait for debounce time
        adc_key_in = analogRead(0);            // read the value from the sensor  
        key = get_key(adc_key_in);            // convert into key press
        if (key != oldkey)
        {
            digitalWrite(ledPIN,HIGH);
            oldkey = key;
            if (key >=0)
            {
                 lcd.cursorTo(2, 0); //line=2, x=0
                switch(key)
                {
                case upKey:
                    lcd.printIn(msgs[key]);
                    // your code here
                    break;
                case downKey:
                    lcd.printIn(msgs[key]);
                    // your code here
                    break;
                case rightKey:
                    lcd.printIn(msgs[key]);
                    // your code here
                    break;
                case leftKey:
                    lcd.printIn(msgs[key]);
                    // your code here
                    break;
                case selectKey:
                    lcd.printIn(msgs[key]);
                    // your code here
                    break;
                }
            }
            digitalWrite(ledPIN, LOW);
        }
    }
}

This does nearly the same, like the original code, but I think it's more readable :slight_smile:

Currently I'm working on a menu system, which work's nearly like your wish,
You can use up and down to select a menu topic, left and right to choose options and only in the last menu topic, you can start the programm by pressing the select key.

But this code from nuelectronics has some disadvantages:

  • the modded 4 Bit library is ver slow, especially when positioning the cursor
    The LiquidCrystal library from Arduino 0013 ist much faster (in my tests the
    4bit library need 130ms for writing on the LCD while LiquidCrystal only needs
    2-3ms!) But you have to modify the distributed library, 'cause it requires the
    read/write pin of the display, which is fixed connected to ground on the LCD
    keypad shield.

  • The key detection of this code, works with delays in the main loop, so the program
    can't do other things, while it's waiting for bounce time. My current program
    (in the state of a proof-of -concept) does the key detection and bounce time
    by comparing millis in the main loop, so the programm is able detect the
    key and save an "event" without stopping the main programm

  • Some other things I've done in the last days/weeks is to define and display characters,
    so I can use little "Icons" instead of text messages. Another thing was to figure out,
    how you can use the chars from LCD character map, which have a ascii code greater
    then 127 (which is largern then the value of an unsigned char, which are used by
    Arduino char[] strings)

After tinkering with it all night lastnight I came up with about the same conclusion. What I got lost on was trying to figure out how to define each button. :smiley: Duh 01234 I was so mad yet so happy when I got it.

I am very interested in hearing more about the Icons if you can get them figured out.

Hi,
creating custom characters is really simple:

This code is only tested with the LiquidCrystal library of Arduino 0013, which I’ve patched (commented out every line which uses the read/write pin, deleted the original .o file and recompiled the sketch) to work with the lcd keypad shield.

First you have to define your character, like this

int custom_0[] = { 0x15, 0x1a, 0x15, 0x1a, 0x15, 0x10, 0x10, 0x10}; // checked flag

You can define up to 8 custom characters.

Next include this small function:

// Define a custom char in lcd
int defineCharacter(int ascii, int *data) {
    int baseAddress = (ascii * 8) + 64;  
    // baseAddress = 64 | (ascii << 3);
    lcd.command(baseAddress);
    for (int i = 0; i < 8; i++)
        lcd.write(data[i]);
    lcd.command(128);
    return ascii;
}

now include something like this to setup()

void setup() 
{ 
    lcd.clear();
    
    // set initial values for program
    defineCharacter(0, custom_0);

    lcd.write(0);
}

So, if you want to know, how you can define a custom char, please read this: http://www.geocities.com/dinceraydin/lcd/custom.htm

On a Mac I use “LCD Editor” to define custom characters and test strings for my menu. You can get it here:

http://www.macupdate.com/info.php/id/28724/lcd-editor

There are similar programs for windows, too, but I don’t know any :slight_smile: There’s a web based editor, too, but I didn’t find it, maybe google can help ::slight_smile:

Cheers
KiWiX

– modified

To patch LiquidCrystal (what I really commend) take a look to this thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235496289

Very cool Thank you

Ok I'm lost again

I am looking to make my menu like so:

Option1 ---> Option2 ---> Option3 ---> Option4
| |
Sub1 Sub1
| |
Sub2 Sub2
|
Sub3
|
Sub4

I want to use the R and L keys to navigate through options and then with my desired option on the screen I want to use the up and down keys to navigate through the sub options. When I find the sub option I want to use the select key to activate the action.

I keep getting a duplicate case value error :o

I know there has to be a more efficient way to do this :-[

Here's my horrible attempt at code:

//Key message
char msgs[5][15] = {"Right  ", 
                    "Up  ", 
                    "Down  ", 
                    "Left  ", 
                    "Select " };
int  adc_key_val[5] ={30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;
int Menu;
int Lighting;

#define rightKey    0
#define upKey       1
#define downKey     2
#define leftKey     3
#define selectKey   4
#define NUM_KEYS    5
#define rightKey1   0
#define rightKey2   0
#define rightKey3   0
#define rightKey4   0
#define onoff       2
#define dim         2
#define timer       2
#define color       2

 

void loop()
{
    int key = 0;
    adc_key_in = analogRead(0);                  // read the value from the sensor  
    key = get_key(adc_key_in);                  // convert into key press
    if (key != oldkey)                        // if keypress is detected
    {
        delay(50);                        // wait for debounce time
        adc_key_in = analogRead(0);            // read the value from the sensor  
        key = get_key(adc_key_in);            // convert into key press
        if (key != oldkey)
        {
           // digitalWrite(ledPIN,HIGH);
            oldkey = key;
            if (key >=0)
            {
                 lcd.cursorTo(2, 0); //line=2, x=0
              
              switch(Menu)
                {lcd.printIn("Main Menu ");
                  case rightKey1:
                     {lcd.printIn("Lighting ");
                        // your code here   
                    
                    switch(Lighting)
                        case onoff:
                         {lcd.printIn("ON/OFF ");
                           // your code here
                           break;
                        case dim:
                         {lcd.printIn("Dim ");
                           // your code here
                           break;
                        case timer:
                         {lcd.printIn("Timer ");
                           // your code here
                           break;
                        case color:
                         {lcd.printIn("Color ");
                           // your code here
                           break;
                          
                          break;
                         break;
                  
                  case rightKey2:
                  {lcd.printIn("Temp Settings ");
                    // your code here
                   break;
                  case rightKey3: 
                  {lcd.printIn("Salinity ");
                    // your code here
                    break;
                  case rightKey4:
                  {lcd.printIn("PH ");
                    // your code here
                   break;
                 break;
                }
            }

Oh, the duplicate case error is an easy one :slight_smile:

Just imagine, that the compiler replaces all define values with the given value, so your

case rightKey2:
case rightKey3:
case rightKey3:

Will be translated to

case 0:
case 0:
case 0:

and now your compiler is right :slight_smile:

Cheers
KiWiX

Thanx for the quick response I will give it a try and post results when I get home

still not working. I can’t find any good info on switch and case to understand it.

Any good guides out there? Or if you have time could you explain it for me.

I am assuming I can build a entire menu layout with switch and case

Okay,

Here’s an example, you can try:

// ===================================================================
// Example for LCD Keypad Shield from  http://www.nuelectronics.com/
// -------------------------------------------------------------------
// * Modified to use a patched LiquidCrystal library 
// * Alternative routine to detect keys
// ===================================================================
#include <stdio.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 14, 9, 4, 5, 6, 7);
// ===================================================================
// hardware settings
#define rightKey  0
#define upKey     1
#define downKey   2
#define leftKey   3
#define selectKey 4
#define NUM_KEYS  5
// ===================================================================
// Program parameters
#define minOpt1   5
#define maxOpt1 999
int valueOpt1 = 15;

#define minOpt2   1
#define maxOpt2  99
int valueOpt2 = 10;

#define programMode1 0
#define programMode2 1
#define programMode3 2
int programMode    =  programMode1;

boolean inMainProgram  =  false;

int programmSequence = 0;
#define sequenceModeSelect  0
#define sequenceModeOption  1
#define sequenceModeProgram 2

// first menu line - description of menu level
char sequenceHeader[3][17]  = {"Mode select     ", "Option select   ", "Program start   "};

// second menu line - mode select
char sequenceModes[3][17]   = {"  Mode 1       >", "< Mode 2       >", "< Mode 3        "};
// second menu line - options settings
char sequenceOptions[3][17] = {"Option 1:  ", "Option 2:   ", "no options      "};

void setup() 
{ 
    // initial lcd display while initialize and pc detection
    lcd.clear();
    lcd.print("Freeduino  0.0.1");
    
    programmSequence = sequenceModeSelect;
    inMainProgram = false;
    
    delay(2000);
    updateScreen();
}

// ===================================================================
// main loop with new key detection
int keyEvent  = -1;
int lastEvent = -1;
int countEvent = 0;

//Key message
char msgs[5][3] = {
    "> ", 
    "^ ", 
    "v ", 
    "< ", 
    "* " };

void updateScreen()
{
    lcd.clear();
    lcd.print(sequenceHeader[programmSequence]);
    lcd.setCursor(0,1);
    switch(programmSequence)
    {
        case sequenceModeSelect:
            menuModeSelect( keyEvent );
            break;
        case sequenceModeOption:
            menuOptionSelect( keyEvent );
            break;
        case sequenceModeProgram:
            break;        
    }
}

void loop() 
{
    int keyEvent = detectKey();
    if (keyEvent >= 0)
    {
        switch (keyEvent)
        {
            case upKey:
                if (!inMainProgram)
                {
                    if (programmSequence > sequenceModeSelect)
                        programmSequence--;
                    updateScreen();
                }
                break;
            case downKey:
                if (!inMainProgram)
                {
                    if (programmSequence < sequenceModeProgram)
                        programmSequence++;
                    updateScreen();
                }
                break;
            case rightKey:
            case leftKey:
                if (!inMainProgram)
                {
                    switch (programmSequence)
                    {
                        case sequenceModeSelect:
                            menuModeSelect( keyEvent );
                            break;
                        case sequenceModeOption:
                            menuOptionSelect( keyEvent );
                            break;
                        case sequenceModeProgram:
                            break;
                    }
                }
                break;
            case selectKey:
                lcd.setCursor(0, 1);
                if (lastEvent != keyEvent)
                {
                    lastEvent = keyEvent;
                    countEvent=0;
                }
                else
                    countEvent++;
                lcd.print(msgs[keyEvent]);
                lcd.print(countEvent);
                break;
        }
    }
}

// ===================================================================
// Menu tools

void menuModeSelect( int keyEvent )
{
    switch (keyEvent)
    {
        case rightKey:
            if (programMode < programMode3)
                programMode++;
            break;
        case leftKey:
            if (programMode > programMode1)
                programMode--;
            break;
    }
    lcd.setCursor(0,1);
    lcd.print( sequenceModes[programMode] );
}

void menuOptionSelect( int keyEvent )
{
    char cbuf[4] = "   ";
    lcd.setCursor(0,1);
    lcd.print(sequenceOptions[programMode]);
    switch (keyEvent)
    {
        case rightKey:
            switch (programMode)
            {
                case programMode1:
                    if (valueOpt1 < maxOpt1)
                        valueOpt1++;
                    break;
                case programMode2:
                    if (valueOpt2 < maxOpt2)
                        valueOpt2++;
                    break;
            }
            break;
        case leftKey:
            switch (programMode)
            {
                case programMode1:
                    if (valueOpt1 > minOpt1)
                        valueOpt1--;
                    break;
                case programMode2:
                    if (valueOpt2 > minOpt2)
                        valueOpt2--;
                    break;
            }
            break;
    }
    switch(programMode)
    {
        case programMode1:
            if (valueOpt1 > minOpt1)
                lcd.print("<");
            else
                lcd.print(" ");
            sprintf(cbuf,"%3d",valueOpt1);
            lcd.print(cbuf);
            if (valueOpt1 < maxOpt1)
                lcd.print(">");
            else
                lcd.print(" ");
            break;
        case programMode2:
            if (valueOpt2 > minOpt2)
                lcd.print("<");
            else
                lcd.print(" ");
            sprintf(cbuf,"%2d",valueOpt2);
            lcd.print(cbuf);
            if (valueOpt2 < maxOpt2)
                lcd.print(">");
            else
                lcd.print(" ");
            break;
    }
}

// ===================================================================
// Lcd tools

void clearLine(int line)
{
    lcd.setCursor(0,line);
    lcd.print("                ");
    lcd.setCursor(0,line);
}

// ===================================================================
// Define a custom char in lcd
int defineCharacter(int ascii, int *data) {
    int baseAddress = (ascii * 8) + 64;  
    // baseAddress = 64 | (ascii << 3);
    lcd.command(baseAddress);
    for (int i = 0; i < 8; i++)
        lcd.write(data[i]);
    lcd.command(128);
    return ascii;
}

// ===================================================================
// Convert ADC value to key number

int adc_key_val[NUM_KEYS] ={ 30, 150, 360, 535, 760 };
int get_key(unsigned int input)
{
    int k;
    for (k = 0; k < NUM_KEYS; k++)
    {
        if (input < adc_key_val[k])
            return k;
    }
    if (k >= NUM_KEYS)
        k = -1; // No valid key pressed
    return k;
}

// ===================================================================
// new key detection routine, without delays!

int     lastKeyEvent = 0;
int     curKeyEvent  = 0;
int     keyToReturn  = 0;
boolean keyToProcess = false;
int     adc_key_in   = 0;

int detectKey()
{
    keyToReturn = -1;
    adc_key_in = analogRead(0);         // read the value from the sensor  
    curKeyEvent = get_key(adc_key_in);      // convert into key press
    if (curKeyEvent != lastKeyEvent)
    {
        if (!keyToProcess) 
        {
            lastKeyEvent = curKeyEvent;
            keyToProcess = true;
        }
        else
        {
            keyToReturn = lastKeyEvent;
            lastKeyEvent = -1;
            keyToProcess = false;
        }
    }
    return keyToReturn;
}

// ===================================================================

The menu will have 3 levels

  1. Choose program mode
    1st and 2nd mode has options, 3rd not
  2. Select the value
    1st program mode has a value between 5 and 999
    2nd program mode has a value between 1 and 99
    3rd program mode don’t have an option
  3. Start your program

About the menu and LCD keypad:

  1. you have to patch LiquidCrystal (I told before)
  2. i use an alternative routine to detect a key pressed,
    without blocking the main loop, so it looks a bit different

So copy & paste, compile, upload and test and then try to read and learn :slight_smile:

Cheers
KiWiX

–modified 23:55

I forget, it works different as you mentioned above:

  • with right and left you change the values
  • with up and down you change the menu level

But if you understand my code, you could simple change the behavior :slight_smile:

The size of the sketch is ~5kB

–modified 23:58
There was a small bug in line 193

– modified 23:59
if someone has tips to optimize this code, please post them here

WoW thank you so much. I can't wait to get home and give this a try.

Ok kiwix I tried to patch my LC files but after upload it still won't read key presses. could you paste you LC file for me? I'm not sure what I may have done wrong.

I commented out

//pinMode(_rw_pin, OUTPUT);

and

//digitalWrite(_rw_pin, LOW);

Is that right?

Yes!

got it kiwix.. I commented out the wrong line.

Hi,

does the sample code runs on your device, now?

KiWiX

yep looks great

Now I'm trying to figure out how to add items to the menu.
It seems that just adding a case and naming it is only one step in the process.

You have been a big help. now I can tinker with the layout until I understand it.

Ah.

That's right, In the main loop I check for a defined var.
I take a look at it, it's better to check for the size of the
array, so it's easier to modify the menu.

A new to do for the next days :slight_smile:

KiWiX

Just got my Arduino and LCD from ekitszone 2 days ago.
The idea was to control some devices and have a nice menu structure to do that.
The instructions given by KiWiX got me up and running on the menu side of things in no time at all!!
Also the issue of creating custom characters is no issue any more and all that in less than 2 days. I have to say I am impressed.

Thanks for that!!

Agreed I am still fine tuning mine but here’s what I have so far:

#include <stdio.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 14, 9, 4, 5, 6, 7);

 
// ===================================================================
// hardware settings
#define rightKey  0
#define upKey     1
#define downKey   2
#define leftKey   3
#define selectKey 4
#define NUM_KEYS  5
// ===================================================================
// Program parameters
#define minOpt1   5
#define maxOpt1 999
int valueOpt1 = 15;

#define minOpt2   1
#define maxOpt2  99
int valueOpt2 = 10;

#define programMode1 0
#define programMode2 1
#define programMode3 2
#define programMode4 3
#define programMode5 4
#define programMode6 5
int programMode    =  programMode1;

boolean inMainProgram  =  false;

int programmSequence = 0;
#define sequenceModeSelect  0
#define sequenceModeOption  1

// first menu line - description of menu level
char sequenceHeader[3][17]  = {"Main Menu     ", "    Options     ", "Program start   "};

// second menu line - mode select
char sequenceModes[6][17]   = {"  Temperature  >","<   Lighting   >","<Timer settings>","< Light Color  >","<   Salinity   >","<      PH       "};
// second menu line - options settings
char sequenceOptions[6][17] = {"Temp:           ", "Light:          ", "Time:           ","Color:          "," Connect Sensor "," Connect Sensor "};

void setup()
{
    // initial lcd display while initialize and pc detection
    lcd.clear();
    lcd.print("Reef control 1.0 ");
    programmSequence = sequenceModeSelect;
    inMainProgram = false;
   
    delay(2000);
    updateScreen();
}

// ===================================================================
// main loop with new key detection
int keyEvent  = -1;
int lastEvent = -1;
int countEvent = 0;

//Key message
char msgs[5][3] = {
    "> ",
    "^ ",
    "v ",
    "< ",
    "* " };

void updateScreen()
{
    lcd.clear();
    lcd.print(sequenceHeader[programmSequence]);
    lcd.setCursor(0,1);
    switch(programmSequence)
    {
        case sequenceModeSelect:
            menuModeSelect( keyEvent );
            break;
        case sequenceModeOption:
            menuOptionSelect( keyEvent );
            break;
               
    }
}

void loop()
{
    int keyEvent = detectKey();
    if (keyEvent >= 0)
    {
        switch (keyEvent)
        {
            case upKey:
                if (!inMainProgram)
                {
                    if (programmSequence > sequenceModeSelect)
                        programmSequence–;
                    updateScreen();
                }
                break;
            case downKey:
                if (!inMainProgram)
                {
                    if (programmSequence < sequenceModeOption)
                        programmSequence++;
                    updateScreen();
                }
                break;
            case rightKey:
            case leftKey:
                if (!inMainProgram)
                {
                    switch (programmSequence)
                    {
                        case sequenceModeSelect:
                            menuModeSelect( keyEvent );
                            break;
                        case sequenceModeOption:
                            menuOptionSelect( keyEvent );
                            break;

                    }
                }
                break;
           // case selectKey:
             //   lcd.setCursor(0, 1);
              //  if (lastEvent != keyEvent)
              //  {
              //      lastEvent = keyEvent;
               //     countEvent=0;
               // }
               // else
              //      countEvent++;
              //  lcd.print(msgs[keyEvent]);
              //  lcd.print(countEvent);
              //  break;
        }
    }
}

// ===================================================================
// Menu tools

void menuModeSelect( int keyEvent )
{
    switch (keyEvent)
    {
        case rightKey:
            if (programMode < programMode6)
                programMode++;
            break;
        case leftKey:
            if (programMode > programMode1)
                programMode–;
            break;
    }
    lcd.setCursor(0,1);
    lcd.print( sequenceModes[programMode] );
}

void menuOptionSelect( int keyEvent )
{
    char cbuf[4] = "   ";
    lcd.setCursor(0,1);
    lcd.print(sequenceOptions[programMode]);
    switch (keyEvent)
    {
        case rightKey:
            switch (programMode)
            {
                case programMode1:
                    if (selectKey)
                    lcd.setCursor(6, 1);
                    lcd.print("Room");
                    break;
                   
                case programMode2:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("ON/OFF");
                    break;
                   
                case programMode3:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("ON/OFF");
                    break;
                   
                case programMode4:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("Blue");
                    break;
            }
            break;
        case leftKey:
            switch (programMode)
            {
                case programMode1:
                    if (selectKey)
                    lcd.setCursor(6, 1);
                    lcd.print("Tank");
                    break;
                case programMode2:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("Dimming");
                    break;
                   
                case programMode3:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("Dimming");
                    break;
                   
                case programMode4:
                    if (selectKey)
                    lcd.setCursor(7, 1);
                    lcd.print("White");
                    break;
            }
            break;
    }
   
}

// ===================================================================
// Lcd tools

void clearLine(int line)
{
    lcd.setCursor(0,line);
    lcd.print("                ");
    lcd.setCursor(0,line);
}

// ===================================================================
// Define a custom char in lcd
int defineCharacter(int ascii, int *data) {
    int baseAddress = (ascii * 8) + 64;  
    // baseAddress = 64 | (ascii << 3);
    lcd.command(baseAddress);
    for (int i = 0; i < 8; i++)
        lcd.write(data[i]);
    lcd.command(128);
    return ascii;
}

// ===================================================================
// Convert ADC value to key number

int adc_key_val[NUM_KEYS] ={ 30, 150, 360, 535, 760 };
int get_key(unsigned int input)
{
    int k;
    for (k = 0; k < NUM_KEYS; k++)
    {
        if (input < adc_key_val[k])
            return k;
    }
    if (k >= NUM_KEYS)
        k = -1; // No valid key pressed
    return k;
}

// ===================================================================
// new key detection routine, without delays!

int     lastKeyEvent = 0;
int     curKeyEvent  = 0;
int     keyToReturn  = 0;
boolean keyToProcess = false;
int     adc_key_in   = 0;

int detectKey()
{
    keyToReturn = -1;
    adc_key_in = analogRead(0);         // read the value from the sensor  
    curKeyEvent = get_key(adc_key_in);  // convert into key press
    if (curKeyEvent != lastKeyEvent)
    {
        if (!keyToProcess)
        {
            lastKeyEvent = curKeyEvent;
            keyToProcess = true;
        }
        else
        {
            keyToReturn = lastKeyEvent;
            lastKeyEvent = -1;
            keyToProcess = false;
        }
    }
    return keyToReturn;
}

// ===================================================================

Hey kiwix
I am trying to figure out how to now add the functions to this menu.

for example, after

case rightKey:
            switch (programMode)
            {
                case programMode1:
                    if (selectKey)
                    lcd.setCursor(6, 1);
                    lcd.print("Room");
                    break;

I want to make the select key pull up the readings from the room temperature.

So basically how do you call on the select key within switch/case and make it call up a set of functions based on the current selection on the screen not the last key press?

Any ideas