hi, i have a function that converts entries from a keypad to string, but i want it to convert that string into an integer, and return its value.
#include <Keypad.h>
const int ROW_NUM=4;
const int COLUMN_NUM=4;
char keys[ROW_NUM][COLUMN_NUM]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte pin_rows[ROW_NUM] = {2,3,4,5};
byte pin_column[COLUMN_NUM] = {6,7,8,9};
Keypad keypad = Keypad (makeKeymap(keys), pin_rows, pin_column,ROW_NUM, COLUMN_NUM);
String input_password;
int numm;
void setup() {
Serial.begin(9600);
input_password.reserve(32);
}
void loop() {
char key = keypad.getKey();
if(key){
if (key=='C'){
Serial.println("Ingrese su ID: ");
CCgetId();
Serial.println(CCgetId());
Serial.println(numm);
}
}
}
int CCgetId(){
String input_password;
input_password = "";
char key = keypad.getKey();
while(key != '#'){
key = keypad.waitForKey();
if(key!='#'){
input_password+=key;
}
}
numm = input_password.toInt();
return numm;
}
see, if i was to put
Serial.println(numm);
right after defining numm inside the function, it´d write it, but the function itself won´t actually return anything to the loop.