Matrix keypad and 16x2 RGB LCD...

Ok, so I’m trying to use a matrix 3x4 key pad 0123456789*# with my arduino and display the pressed buttons on my 16x2 RGB LCD. I’m running into an issue that I’m not quite understanding…

If I print to the serial console the numbers come out correctly. However when printing to the LCD they come out as mostly unreadable characters. And it never prints JUST 1 character.

The issue with not printing just 1 character isn’t much of an issue as I believe I may know what’s causing that but why is it when I print to the LCD the characters (if any are printed at all) are not correct?

Below is my code, the commented out stuff is just to cut back on some of the unnecessary stuff since I will not have my LCD changing colors while it’s actually being used. I will write code for that to change it with a combination of buttons or something… no biggie at the moment.

If there’s anything else you need to know let me know please.

// include the library code:
#include <LiquidCrystal.h>
#include <Wire.h>
#include <Keypad.h>

#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6
const byte rows = 4;
const byte cols = 3;
char keys[rows][cols] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[rows] = {2,3,4,5};
byte colPins[cols] = {6,7,8};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

 
// you can change the overall brightness by range 0 -> 255
int brightness = 255;
 
void setup() {
  
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("RGB 16x2 Display  ");
  lcd.setCursor(0,1);
  lcd.print(" Multicolor LCD ");
  keypad.begin(makeKeymap(keys));
  
  /*pinMode(REDLITE, OUTPUT);
  pinMode(GREENLITE, OUTPUT);
  pinMode(BLUELITE, OUTPUT);
 */
  brightness = 100;
}
 
int count=0;
void loop() {
    
  /*for (int i = 0; i < 255; i++) {
    setBacklight(i, 0, 255-i);
    delay(5);
  }
  for (int i = 0; i < 255; i++) {
    setBacklight(255-i, i, 0);
    delay(5);
  }
  for (int i = 0; i < 255; i++) {
    setBacklight(0, 255-i, i);
    delay(5);
  }*/
  char key = keypad.getKey();
  if(key != NO_KEY) {
    Serial.print(key);
    lcd.print(key);
    count++;
    if (count==17) 
    {
      lcd.clear();
      count=0;
    }
  }
}

 
 
void setBacklight(uint8_t r, uint8_t g, uint8_t b) {
  // normalize the red LED - its brighter than the rest!
  r = map(r, 0, 255, 0, 100);
  g = map(g, 0, 255, 0, 150);
 
  r = map(r, 0, 255, 0, brightness);
  g = map(g, 0, 255, 0, brightness);
  b = map(b, 0, 255, 0, brightness);
 
  // common anode so invert!
  r = map(r, 0, 255, 255, 0);
  g = map(g, 0, 255, 255, 0);
  b = map(b, 0, 255, 255, 0);
  /*Serial.print("R = "); Serial.print(r, DEC);
  Serial.print(" G = "); Serial.print(g, DEC);
  Serial.print(" B = "); Serial.println(b, DEC);*/
  analogWrite(REDLITE, r);
  analogWrite(GREENLITE, g);
  analogWrite(BLUELITE, b);
}