Hello, I'm new here. ![]()
Anyways, I am playing with a keypad on my Leonardo board.
If I run this code, it will output the numbers I press to the serial monitor....
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //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);
 }
Â
}
I was playing with this and wanted to also make the LED on the board blink when a number is pressed so I added...
#include <Keypad.h>
int led = 13;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
 {'1','2','3'},
 {'4','5','6'},
 {'7','8','9'},
 {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
 Serial.begin(9600);
 pinMode(led, OUTPUT);
}
Â
void loop(){
 char key = keypad.getKey();
Â
 if (key){
 Serial.println(key);
 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000);       // wait for a second
 digitalWrite(led, LOW);  // turn the LED off by making the voltage LOW
 delay(1000);
 }
Â
}
When I run this it will blink the LED on the board but it wont ouput the numbers to the serial monitor at the same time.
Why not?