Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
No comments on using the ADC approach which uses fewer pins?
That would likely be because you've switched around the row(inputs) and column(outputs) pins from what the keypad module in post #37 is expecting,going to reevaluate what I have and why it doesn't work
Module Keypad12
{
Column1 = PORTX.0
Column2 = PORTX.1
Column3 = PORTX.2
PORTX.3 NC
Row1 = PORTX.4
Row2 = PORTX.5
Row3 = PORTX.6
Row4 = PORTX.7
}
// validate data port...
#option KEYPAD_PORT = PORTB
#if IsOption(KEYPAD_PORT)
#if Not IsValidPort(KEYPAD_PORT)
#error KEYPAD_PORT, "Invalid option. Keypad must be connected to a valid port name."
#endif
#option _KEYPAD_PORT_TRIS = GetTRIS(KEYPAD_PORT)
#endif
// bring PORT and TRIS options into the module
Dim
FKeyPort As KEYPAD_PORT,
FKeyPortTris As _KEYPAD_PORT_TRIS
Public Function Value() As Byte
Dim Counter As Byte
Dim RowData As Byte
Dim ColData As Byte
Result = 0
Counter = 0
For Counter = 0 To 2 //
FKeyPortTris = $FF // Make all pins inputs
FKeyPortTris.Bits(Counter) = 0 // Make a single Column an output
FKeyPort.Bits(Counter) = 1 // and set it high
If (FKeyPort >> 4) <> 0 Then // Check if any Rows are "High"
Coldata = Counter
If FKeyPort.4 = 1 Then
RowData = 1
ElseIf FKeyPort.5 = 1 Then
RowData = 4
ElseIf FKeyPort.6 = 1 Then
RowData = 7
ElseIf FKeyPort.7 = 1 Then
RowData = 10
EndIf
Result = Coldata + RowData
Break
EndIf
Next
End Function
Public Sub Debounce()
While Keypad12.Value <> 0 // Check if key is pressed
DelayMS(10) // Wait for 10mS
Wend
End Sub
FKeyPortTris = $FF // Make all pins inputs
End
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
here is my schematic
the posted schematic is my actual pcb
yes I have verified all my connections