Hello,
I am new to arduino, I have a 4 x 4 keypad working well. Now, I need to use the keypad to input 2 digit numbers, say 5 and 2, I want to store these two digits into an array called 'keypressed' which has a size of 2.
Basically, I want to store the 1st input to keypressed[0] and the 2nd input to keypressed[1] and then print out as a two digit number '52' when '#' is being pressed.
I am having difficulty storing the 2nd digit with a for loop, any help? Thanks in advance!
Code is provided:
#include <Keypad.h>
int i=0;
long keypressed[3];
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','6','9','#'},
{'A','B','C','D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {9, 8, 7, 6};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}
void loop(){
for (i=0;i<3;i++){
if (keypressed != NO_KEY){
keypressed = keypad.getKey();
_ if (keypressed == '#'){_
_ Serial.println(keypressed[0]10+keypressed[1]);_
_ }_
_} _
_ }*_
}