//Excuse me sir ... I have three variables are v1,v2,v3 and for each one I would to enter decimal value suppose that value v1=1.3;v2=1.5;v3=3.5; how to send that from keypad 4*4 then store var and put on LCD display.
#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','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {17,16,15,14};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
//lcd.init();
//lcd.commandWrite(0x0F);
//lcd.clear();
Serial.begin(9600);
}
void loop()
{
v1 = GetNumber();
Serial.print("V1 = ");Serial.print(v1);Serial.println();
v2 = GetNumber();
Serial.print("V2 = ");Serial.print(v2);Serial.println();
v3 = GetNumber();
Serial.print("V3 = ");Serial.print(v3);Serial.println();
}
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':case '.':
//lcd.print(key);
num = num * 10 + (key - '0');
break;
case 'C':
num = 0;
//lcd.clear();
break;
}
key = kpd.getKey();
}
return num;
}
[code][/#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','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {17,16,15,14};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
//lcd.init();
//lcd.commandWrite(0x0F);
//lcd.clear();
Serial.begin(9600);
}
void loop()
{
v1 = GetNumber();
Serial.print("V1 = ");Serial.print(v1);Serial.println();
v2 = GetNumber();
Serial.print("V2 = ");Serial.print(v2);Serial.println();
v3 = GetNumber();
Serial.print("V3 = ");Serial.print(v3);Serial.println();
}
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':case '.':
//lcd.print(key);
num = num * 10 + (key - '0');
break;
case 'C':
num = 0;
//lcd.clear();
break;
}
key = kpd.getKey();
}
return num;
}
[/code]