'convert char A[] to double
I have an arduino code that inputs volume in a char datatype, I want to convert it to double, Ive tried using atof but it wont work. Whats the problem from my code. Sorry Newbie here!!
double v;
int data_count = 0;
int i;
char Data[16];
char volume[16];
char inputTime[16];
// Define the Keymap for Keypad
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'.', '0', '#', 'D'}
};
lcd.setCursor(0, 0);
lcd.print("Input Volume:");
if (customKey != NO_KEY && customKey != '#'
&& customKey != 'A' && customKey != 'B' && customKey != 'C'
&& customKey != 'D') {
Data[data_count] = customKey;
lcd.setCursor(data_count, 1);
lcd.print(Data[data_count]);
data_count++;
}
if (customKey == '#') {
volumelength = data_count;
for (i = 0; i < volumelength; i++) {
volume[i] = Data[i];
}
clearData();
nextstate();
data_count = 0;
v = atof(volume);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
