I want to be able to type numbers on keypad like 0000 or any other number that starts with zero with the code below:
#include <Keypad.h>
#include <TM1637Display.h>
#include <Wire.h>
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] = {8, 7, 6, 5};
byte colPins[COLS] = {4, 3, 2};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int keyNum = 0;
const int CLK = 10; //Set the CLK pin connection to the display
const int DIO = 9; //Set the DIO pin connection to the display
TM1637Display display(CLK, DIO); //set up the 4-Digit Display.
void setup()
{
Serial.begin(9600);
for(int i = 0; i< 3; i++)
display.setBrightness(5); //set the diplay to maximum brightness
}
void loop(){
char key = keypad.getKey();
if(key){
if(key==''|| key== '#'){
keyNum = 0;
}
else{
if(keyNum<=999){
keyNum = (keyNum10) + (int(key)-48);
}
}
}
display.showNumberDec(keyNum);
}
Any help????