Geerings all.
i have a problem to read for the second time the keypad in a switch case senario.
i am reading a keypad to fill an 4 digit array and when i press # it wil start to reed the array bit for bit and does som actions based on the read action.
so it reads a 1 it is putting some outputs to high.
that part is working fine.
One of the steps is when it reads a bit with the value 4 it shoud start a second question witch should hav actions on the keypad again.
and based on that is should take further actions based on the autcome of that keypad entry.
but it wont start the second keypad read. ( it is a switch case inside a switch case )
whats wrong with the code ( or my way of thinking this was right )
Greetings adriaan
void lokadresisGoed()
{
\\some code to reset outputs
for (int f = 0; f < 5; f++)
{
p = (locadres[f] - '0');
switch (p)
{
case 0:
{
//some code to send zero to outputs
break;
}
case 1:
{
//some code to send one to outputs
break;
}
case 2:
{
//some code to send two to outputs
break;
}
case 3:
// and so on for 3 to 9
break;
}
case 9:
{
//some code to send nine to outputs
break;
}
default:
{
//some code to set all outputs to off
}
}
}
//some code to ask if the direction is correct and run the direction test
// to be answered with #=Yes / *=NO
//This part is not working.
//only when i press 2 times the # key it will go back to the main program
char firstkey = customKeypad.getKey();
firstkey = NO_KEY;
if (firstkey != NO_KEY)
{
switch(firstkey)
{
case '*':
{
// some code to run when * is pressed
// some code with an question on the lcd
// answered with #=yes / *=NO
char subkey = customKeypad.getKey();
if (subkey !=NO_KEY)
{
switch(subkey)
{
case '*':
{
//some code to change direction and run the direction test
break;
}
case '#':
{
//some code run when direction is correct
}
default:
{
}
}
}
}
case '#':
{
//Some code run when direction is correct
default:
{
}
}
}
}
void loop () {
char key = customKeypad.getKey();
if (key != NO_KEY)
{
switch(key)
{
case '#':
lcd.clear();
lcd.setCursor(0,0);
lcd.print("type adres ");
lcd.setCursor(0,1);
lcd.print("Adres : ");
lcd.setCursor(16,1);
lcd.print("A=Enter C=clear");
lcd.setCursor(8,1);
z=0;
break;
case 'A':
delay(100);
lokadresisGoed();
break;
case 'C':
delay(100);
memset(locadres,0,sizeof(locadres));
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Type adres ");
lcd.setCursor(0,1);
lcd.print("Adres : ");
lcd.setCursor(16,1);
lcd.print("A=Enter C=Clear");
lcd.setCursor(8,1);
z=0;
break;
default:
// Serial.println(key);
lcd.print(key);
locadres[z]=key;
z++;
}
}
}