Quote Originally Posted by Experimenter View Post
mainloop:
gosub getkey
lcdout 254, 192, "key=",#key, " " ; line 2
if portD.0 = 0 then gosub flash
goto mainloop
flash:
portD.4=1
pause 500
portD.4=0
return

getkey:
pause 50 ;debounce


getkeyu:
' Wait for all keys up
PORTB = 0 ;all output pins low
TRISB = 110000 ;bottom 4 pins out, top 4 pins in
If ((PORTB >> 4) != 001111) Then getkeyu ' If any keys down, loop
Pause 50 ;debounce


getkeyp:
' Wait for keypress
For col = 0 To 3 ' 4 columns in keypad
PORTB = 0 ' All output pins low
TRISB = (dcd col) ^ $ff ' Set one column pin to output
row = PORTB >> 4 ' Read row
If row != 001111 Then gotkey ' If any keydown, exit
Next col
Goto getkeyp ' No keys down, go look again


' Change row and column to key number 1-12
gotkey:
key = (col * 3) + (ncd (row ^ 001111)) ;4RX3C matrix
return
Your program starts at Mainloop then gosubs to getkey and loops round getkeyp until a key is pressed when a key is pressed then it returns to mainloop. So it never will execute the 'if portD.0 = 0 then gosub flash' statement until the keypad is pressed. This why the push button does not work. Also portD.0 must be 0 when the button is not pressed as it flashes when the keypad is pressed.

Hope this helps.

I like your programing style as it is easy for me to follow.