Input decimal number using 4by4 keypad ?

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;
}

I can see nowhere in your code where you test for the input of the decimal point and deal with it.

Store your keypad input in a null terminated character array and convert that to float using e.g. atof

UKHeliBob,

Sorry I use in this way

    {
         case NO_KEY:
            break;

         case '0': case '1': case '2': case '3': case '4':
         case '5': case '6': case '7': case '8': case '9':
         case '.':
            num = num * 10 + (key - '0');
            break;

sterretje,
I try to learn your point. :frowning:

         case '.':
            num = num * 10 + (key - '0');

The ASCII code for a full stop is 46. The ASCII code for '0' is 48. Your code is not going to work, is it ?

Do what has been suggested and store each character in an array of chars as it is received. Terminate the array with a zero then use the atof() function to convert the array to a float.

Please visit "entering decimals with keypad - Programming Questions - Arduino Forum" can get the answer