hey all,
the setup is this: 12 button keypad (phone style), 3 chars of 7 segment display. all of these items are coded and working like they should be.
what i want to be able to do is punch in any non-zero number on the keypad to be able to send to something, and have it display what you're entering while entry is happening.
the problem is i CANNOT work out how to do this properly. the startup number is 0, which then looks for the first input as the ones column. one digit numbers alone work fine, but...
after that i'm totally screwed. i can't figure out the logic for "when another key comes in, move the first number to the tens column and then make the ones column the number just entered" without the display reading out the first number twice in a row. i've tried about 10 different variations of if/then statements to try to make it work to no avail, so before i get too frustrated and start throwing electronics around the room...
can anyone help? ![]()
void loop(){
char customKey = cusomKeypad.getKey();
if (customKey != NO_KEY){ // look for key presses
if(outputnum == 0) { // anything above default should do something
ones = customKey; // put first number entered in ones column
outputnum = ones; // set display
tens = (ones * 10); // second column / tens, used if another number is entered
}
if(outputnum > 9 && outputnum < 100)) { // i hate my life
ones = customKey;
outputnum = (tens + ones);
}
// clear everything and drop back to 0 on getting key 11
if ( customKey == 11 ) { outputnum = 0; ones = -1; tens = -1; hundreds = -1;}
} // if:key check
setDisp(outputnum); // 7seg function
} // main loop