i working a add menu to an exiting astronomy program i need to get the switch case to work inside of a while loop; in the function location, polarisRA, polarisAH. when i go into polarisAH or other two. i need to enter in data in three variables. i am using '*' to reset if miss type occurred or '#' as enter key but it does the lcd print and to menu it skips the in between
char keypressed = myKeypad.getKey();
while (keypressed ='D'){
switch(myKeypad.getKey()){
case 'A': Location(); break;
case 'B': PolarisRA(); break;
case 'C': PolarisAH(); break;
case 'D': loop(); break;
}
}
Calling loop() from this function is not a good idea.
Thy while loop condition never changes, while the loop is running. If it ever starts, it will end only when you run out of stack space because of the recursive calls.
You really need some comments in this code to explain what it is trying to do.
while (keypressed [color=red][b]=[/b][/color]'D'){
This is overwriting keypressed and putting 'D' as its value... this is not a test (which needs ==)
Even with == How you can exit that while remains a question though since keypressed is a local variable not changed in the switch/case... agree with Paul you'd better trying to work out exactly what you are trying to achieve