Problem using Keypad to control GLCD menu

Hello everyone, I am designing a tree menu for my project with GLCD that controlled using a 4x4 keypad that i’m also using in the program later. I’m using the U8G2lib library and KEYPAD library. The whole idea is to use the right side of the keypad (A,B,C,D) to control the keypad menu.
But it seems like they don’t work together, when I try the keypad separately it works great, but when I try using the keypad with the GLCD code the keypad don’t seems to work with the keypad and do not respond to it.

By the way, I will add more options to the menu I just want to figure out why this example don’t work first.

#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8);
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKey[ROWS][COLS] = {
  {'1','2','3','Y'},
  {'4','5','6','A'},
  {'7','8','9','M'},
  {'.','0','\r','N'}
};
byte rowPins[ROWS]={39,41,43,45};
byte colPins[COLS]={31,33,35,37};
Keypad customKeypad = Keypad(makeKeymap(hexaKey), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial1.begin(9600);
  Serial.begin(9600);
  u8g2.begin();
}

void loop() {
  char customKey = customKeypad.getKey();
   if (customKey)
    Serial.println(customKey);
  u8g2.clearBuffer();					// clear the internal memory
  u8g2.setFont(u8g2_font_courB10_tf );	// choose a suitable font
  u8g2.drawStr(0,9,"STARTING...");	// write something to the internal memory
  u8g2.sendBuffer();					// transfer internal memory to the display
  delay(2000);  
  u8g2.clearBuffer(); // Put the SYSRESET* code here so the addresses will load in the background
  u8g2.setFont(u8g2_font_6x10_tf);
  u8g2.setFontRefHeightAll();    /* this will add some extra space for the text inside the buttons */
  u8g2.userInterfaceMessage("     ", "Select The Required", "Mode Using B/C Buttons", " [C]Manual \n [B]Auto ");

if(customKey == 'M')
{
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
  u8g2.drawStr(0,9,"Manual Selected");  // write something to the internal memory
  delay(1500);
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
  u8g2.drawStr(0,9,"Proccess Began");  // write something to the internal memory
  }
}

//if(keyPress = 'A')
//{
//  u8g2.clearBuffer();
//  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
//  u8g2.drawStr(0,9,"Automatic Selected");  // write something to the internal memory
//  delay(1500);
//  u8g2.clearBuffer();
//  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
//  u8g2.drawStr(0,9,"Proccess Began");  // write something to the internal memory
//  auto();

Can you please help me understand what went wrong here?

don’t seems to work

What exactly does that mean ?

This looks a little odd

  char customKey = customKeypad.getKey();
  if (customKey)
    Serial.println(customKey);
  u8g2.clearBuffer();          // clear the internal memory
  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
  u8g2.drawStr(0, 9, "STARTING..."); // write something to the internal memory
  u8g2.sendBuffer();          // transfer internal memory to the display
  delay(2000);
  u8g2.clearBuffer(); // Put the SYSRESET* code here so the addresses will load in the background
  u8g2.setFont(u8g2_font_6x10_tf);
  u8g2.setFontRefHeightAll();    /* this will add some extra space for the text inside the buttons */
  u8g2.userInterfaceMessage("     ", "Select The Required", "Mode Using B/C Buttons", " [C]Manual \n [B]Auto ");

Why are you clearing and writing to the display every time through loop() ?

The part that doesn't work is the keypad, when i'm trying to use it with the GLCD code it doesn't work (to give an example I used a line in the code to print what I press through the Serial monitor and it didn't showed up, compered to the Keypad Example, which worked just fine with the serial monitor.)
Now clearing the GLCD in the loop is because I'm quit new here, and that the only way i know for writing and rewriting stuff to the GLCD :slight_smile: I am planing to add another functions by calling them from the loop (for example manual sub menu that will open a "sub menu" loop within the main void loop())

if(customKey == 'M') // M stands for manual mode
{
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
  u8g2.drawStr(0,9,"Manual Selected");  // write something to the internal memory
  delay(1500);
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_courB10_tf );  // choose a suitable font
  u8g2.drawStr(0,9,"Proccess Began");  // write something to the internal memory
> manual();
  }

Just to make it clear, when I press the buttons B/C on the keypad, (That in the code I called A/M) they should trigger the if statement (One if statement for pressing "M" and one for pressing "A" )