hi sorry for my bad english,
i trying to create number input like calculator,
example =
if i press in keypad button "1", then i press keypad button "2" then the result is 12(twelve),
then if i press keypad button "3", the result is 123(one hundred twenty-three),,,etc
but my problem is converting from char type to int type,
i google it for a hour and found nothing that i looking for,
i found about .atoi and int(), but the result is wrong
this is code if it can help :
#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int led_pin = 13;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {4, 5, 6, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 9, 10, 11}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
char customKey;
long int Value = 0;
long int TempValue = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
lcd.begin(16, 2);
lcd.clear();
lcd.print("LCD");
lcd.setCursor(1, 1);
lcd.print("TEST");
}
void loop() {
// put your main code here, to run repeatedly:
char customKey = customKeypad.getKey();
if (customKey) {
lcd.clear();
Serial.print(" and button pushed is: ");
Serial.println(customKey);
lcd.setCursor(0, 0);
lcd.print(customKey);
//TempValue = ConvertCharToInt(customKey); [color=red]<= this is the problem[/color]
Value = (Value * 10) + TempValue;
lcd.setCursor(0, 1);
lcd.print(Value);
Serial.println(TempValue);
}
}
can somebody help me with the syntax please!!