I am programming a AXIOM CML12S512 board and I succesfully got my counter to count up and count down using a BCD LED display counter hooked up to the ports on the board. Now the issue that I am having is a polling issue with the keypad.
What I want is to exit upon hitting the keypad button "once" and go to the next procedure or exit the program over all.
The problem I am having is that since I created a one second delay for the BCD LED display, every time I hit a button on the keypad I have to push that button several times inorder for it to respond, or I hold it for about 1 second and it reponds then.
Here is my sample code for the counter that I created. Any help would be greatly appreciated.
while( (numPress != '2') && (numPress != '3') ){
//Increment the array and store it
newNumVal = number_array2[index];
index = ((index + 1)%10);
//Delay for the count up
for (timeDelay1 = 0; timeDelay1 < 24; timeDelay1++){
for (timeDelay2 = 0; timeDelay2 < 30000; timeDelay2++){
PTP = newNumVal;
}
}//End of delay.
//Exit the loop using the C on the keypad
numPress = kbhit(0);
}//End of While loop. Jumps out only if kkbhit() has detected a hit on the key pad.
//Check if the count stop or count up button is pressed
if(numPress == '3'){
LCDInit(0); //LCD clear
LCDputs("Start count down\0"); //Display string
count_down(newNumVal); //Call the count_down procedure
}
//return to main
if(numPress == '2'){
terminate();
}
What I want is to exit upon hitting the keypad button "once" and go to the next procedure or exit the program over all.
The problem I am having is that since I created a one second delay for the BCD LED display, every time I hit a button on the keypad I have to push that button several times inorder for it to respond, or I hold it for about 1 second and it reponds then.
Here is my sample code for the counter that I created. Any help would be greatly appreciated.
while( (numPress != '2') && (numPress != '3') ){
//Increment the array and store it
newNumVal = number_array2[index];
index = ((index + 1)%10);
//Delay for the count up
for (timeDelay1 = 0; timeDelay1 < 24; timeDelay1++){
for (timeDelay2 = 0; timeDelay2 < 30000; timeDelay2++){
PTP = newNumVal;
}
}//End of delay.
//Exit the loop using the C on the keypad
numPress = kbhit(0);
}//End of While loop. Jumps out only if kkbhit() has detected a hit on the key pad.
//Check if the count stop or count up button is pressed
if(numPress == '3'){
LCDInit(0); //LCD clear
LCDputs("Start count down\0"); //Display string
count_down(newNumVal); //Call the count_down procedure
}
//return to main
if(numPress == '2'){
terminate();
}