Printing greater than 9 to serial monitor

I’m trying to print a number greater than 9 to the serial monitor but it doesn’t work could someone please help me understand why and possibly give a way to print 10-16 from a 4x4 keypad

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','4'},
  {'5','6','7','8'},
  {'9','10','11','12'},
  {'13','14','15','16'},
};

byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad



Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
   Serial.begin(9600);
}
 
void loop(){
  char key = keypad.getKey();
  
  if (key){
    Serial.println(key);
  }


  
}

‘10’ ‘11’ ‘12’ ‘13’ ‘14’ ‘15’ and ‘16’ are two ascii characters, a char is only one character ;)

Thanks, any idea how I could print them?

Is one of your keys supposed to be a '0' ?

no I'm just trying to print 1-16

What is this going to be used for?

Right now I'm just trying to learn but eventually I'm going to have the number show on a 7 segment display, JY-LKM1638

Let’s do this in two steps.

What do you get when you try this sketch?

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
const char keys[ROWS][COLS] =
{
  {'1', '2', '3', '4'},
  {'5', '6', '7', '8'},
  {'9', 'A', 'B', 'C'},
  {'D', 'E', 'F', 'G'}
};

byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

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

void loop()
{
  char key = keypad.getKey();

  if (key)
  {
    Serial.println(key);
  }

}//END of        loop()

Bed time :sleeping:

#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
const byte keys[ROWS][COLS] =
{
  {1, 2, 3, 4},
  {5, 6, 7, 8},
  {9, 10, 11, 12},
  {13, 14, 15, 16}
};

byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

byte num;

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

void loop()
{
  byte key = keypad.getKey();
  if (key)
  {
    Serial.println(key);
  }
  
}//END of   loop()

Thank you that's exactly what I was trying to do. Can you explain why it works now and didn't before

 {'9','10','11','12'},

Part of your problem is that you need to understand the difference between a single character and two characters. '10' is rubbish. Single characters go in single quotes. 10 has two digits. That is two characters. You can always do a '1' and then a '0'.

If you want those to be just numbers and not ascii then get the ' off of them and just make them numbers.