Hi.
I'm a beginner with Arduino programming and need some advice. My project is a bit bigger, but I'm stuck right now on this (quite simple?) problem.
What I need is read numbers that are typed on o 4x3 keypad, then store them in a variable and put on LCD display. The variables are three, and for each one the user can enter values. My code looks somtehing like this (the setup part is not shown):
void loop()
{
// for 12V -----------------------------------------------------------
char key1 = kpd.getKey();
switch (key1) {
case NO_KEY:
break;case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
lcd.print(key1);
firstvariable = firstvariable* 10 + key1 - '0';
break;case '#':
Serial.println ();
Serial.print ("Value for 12V is: ");
Serial.print (firstvariable );
break;case '*':
firstvariable = 0;
lcd.clear();
Serial.println ();
Serial.print ("Reset value:");
Serial.print (firstvariable );
}
// for 12V end -----------------------------------------------------------
}
This is only for the first value. What I need is when the user press #, the firstvalue is stored, and the program continues on the input of the second value. After the second value, it continues with the input of the last (third) value.
I've tried doing some functions and calling it after the # button press, but with no luck. Can someone please give me a hint, how should it look like?
Thank you.