test VAR Byte scan VAR Byte key_in VAR Byte number VAR Byte main: key_in=INB & 7 'mask bit3 scan=1 DO WHILE key_in<1 scan=scan<<1 'cycle output pins 0-3 IF scan>8 THEN scan=1 OUTA=scan key_in=INB & 7 'test for input LOOP GOSUB number_pressed DO WHILE key_in >0 key_in=INB & 7 ' wait for key release, may need pause to allow for debounce LOOP GOTO main number_pressed: test.HIGHNIB=scan 'combine the nibbles test.LOWNIB=key_in 'to test for which key is pressed SELECT test CASE 17 number="1" CASE 18 number="2" CASE 20 number="3" CASE 33 number="4" CASE 34 number="5" CASE 36 number="6" CASE 65 number="7" CASE 66 number="8" CASE 68 number="9" CASE 129 number="*" CASE 130 number="0" CASE 132 number="#" ENDSELECT RETURN