Hello !
With help of "PaulS" answer
([SOLVED] Keypad number input and store - #4 by system - Programming Questions - Arduino Forum)
I able to store numbers seperately, Now My problem is store decimal numbers seperately. I change the key pad "D" to "." and Change data type "int" to "float" but not succsses Heres the code I try.Please help me.
#include <Keypad.h>
float v1 = 0;
float v2 = 0;
float v3 = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', '.'}
};
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {9, 8, 7, 6};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
}
void loop()
{
v1 = GetNumber();
Serial.println ();
Serial.print (v1);
v2 = GetNumber();
v3 = GetNumber();
}
int GetNumber()
{
int num = 0;
char key = kpd.getKey();
while(key != '#')
{
switch (key)
{
case NO_KEY:
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
num = num * 10 + (key - '0');
break;
case '*':
num = 0;
break;
}
key = kpd.getKey();
}
return num;
}