For x= 0 To 4
If SW_COL1=0 And sw_ROW1=0 //sw_colx =high via pullups until button press then it goes low
Then
key=1
delayms(30)
sw_col1=1//
sw_row2=1 sw_row3=1
ElseIf
SW_COL2=0 And sw_ROW1=0 //searching for LOW
Then
key=2
delayms(30)
sw_row2=1 sw_row3=1
sw_col1=1
'sw_col2=1 sw_row1=1 sw_row3=1 //reset sw+colx
ElseIf
SW_COL3=0 And sw_ROW1=0
Then
key=3
' delayms(30)
'sw_col3=1 'sw_row1=1
sw_row2=1 sw_row3=1
'sw_col3=1 sw_row1=1 sw_row3=1
ElseIf
SW_COL4=0 And sw_ROW1=0
Then
key=4
' delayms(30)
sw_row2=1 sw_row3=1
'sw_row2=1 sw_row3=1
Break
EndIf
Next
' If key<>0 Then
'DelayMS(50)
WriteAt(2,1,"Key: ",DecToStr(key,2))//,( " Cnt: "),DecToStr(Counter,2)
wend