I added the code as supplied.. The digits as entered are displayed as ---- (actually three horizontal lines in a stack) when inputted... When you push * it removes the dashes and displays the digits you hit..
The full code is included here:
/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
String keyIn;
int currentCommand = 0;
char Data[5];
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {28, 26, 24, 22}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {31, 33, 35}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
lcd.begin(15,2);
}
void loop(){
//lcd.begin(15,2);
lcd.setCursor(2,0);
lcd.print("Input Digits");
char key = keypad.getKey();
if(key != NO_KEY) // Do nothing if no key is pressed, incorporated from PaulS's example.
{
if (key != '*') {
Data[currentCommand++] = key;
lcd.setCursor(6 + currentCommand,1);
lcd.print(Data[currentCommand]);
}
else {
int keyIn = atoi(Data);
lcd.setCursor(6,1);
lcd.print(keyIn);
lcd.print(" ");
Serial.println(keyIn);
while(currentCommand !=0){ // This can be used for any array size,
Data[currentCommand--] = 0; //clear for new data
}
}
}
}
I'm / We're gettin there !!
KEYPAD_TEST_as_entered.ino (1.41 KB)