I am using a 4*4 matrix keypad and I just did the setup on hardware and I need to test if it works but it didn't.
I used the keypad test code in the keypad solutions folder and edited the ports to mine. I connected pull-ups to my columns also.
For output, I'm using a 16*4 LCD.
My rows and columns are not organized due to pin availability. I have them as such:
Sorry I couldn't reply in time. I used my phone to make the first post.
Here's the code....
'Program to show the value of the last pressed key on the LCD
#chip16f877a, 20'LCD connection settings
#defineLCD_IO4
#defineLCD_NO_RW
#defineLCD_RSportB.0
#defineLCD_EnableportB.1
#defineLCD_DB4PortB.2
#defineLCD_DB5PortB.3
#defineLCD_DB6PortB.4
#defineLCD_DB7PortB.5'Keypad connection settings
#defineKEYPAD_ROW_1portD.7
#defineKEYPAD_ROW_2portD.6
#defineKEYPAD_ROW_3portD.5
#defineKEYPAD_ROW_4portD.4
#defineKEYPAD_COLUMN_1portC.5
#defineKEYPAD_COLUMN_2portC.4
#defineKEYPAD_COLUMN_3portD.3
#defineKEYPAD_COLUMN_4portD.2'Main loopDo'Get keyTemp=KeypadData'If a key is pressed, then display itIfTemp<>KEY_NONEThenCLSPrintTempWait100msEndIfLoop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If it's the keypad, shouldn't the Proteus simulation work? On the hardware, it could be that your pullup resistors are too low in value. Have you tried measuring the resistance(s) of the switch buttons when pressed? on some of these carbon print membrane keypads the contact resistance could be quite high, not the near zero ohms you might expect with a traditional switch contact.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for this delay. I've been ill for some time.
I'm not really sure why it isn't working.
In the simulation, since I couldn't find a 4 by 4 keypad among the component parts, I used a 4 by 3 and then pulled up the empty column. (I thought this would suffice because I saw in the manual where they said if you're using a 3 by 3 keypad, pull up the unused row and column)
The resistance of each button is roughly 23 ohms.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Very sorry for the delay.
I couldn't find a 4 by 4 keypad among the component parts in proteus, I used a 4 by 3 and then pulled up the empty column. (I thought would work, from the manual)
Okay, let me make the pin changes and get back ASAP
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are 4 gcb keyboard demos that send to terminal and guess are working but not tried them.
#chip16f1938,16
#optionexplicit
#configosc=int; ----- Constants
#defineKEYPAD_ROW_1portb.3
#defineKEYPAD_ROW_2portb.2
#defineKEYPAD_ROW_3portb.1
#defineKEYPAD_ROW_4portb.0
#defineKEYPAD_COL_1portc.0
#defineKEYPAD_COL_2portc.1
#defineKEYPAD_COL_3portc.2
#defineKEYPAD_COL_4portc.3; ----- Define Hardware settings' THIS CONFIG OF THE SERIAL PORT WORKS WITH A MAX232 (or equiv) THEN TO PC' USART settings - CHANGE PORTS if required
#defineUSART_BAUD_RATE9600
#defineUSART_DELAY5ms
#defineUSART_BLOCKINGwait500msDimTEMPasByte; ----- Main body of program commences here.Do'Get keyTemp=KeypadData'If a key is pressed, then display itIfTemp<>KEY_NONEThenHSerPrintTemp'Wait until key is releasedwaitwhileKeypadData<>KEY_NONEEndIfLoop
so I guess this is for a 4x4 keypad cos I can't see where KeypadData is defined or dimmed.
looks like a keyword for a 4x4 keypad. Dunno.sorry.
shouldn't make a difference though. maybe you are using wrong port pins.
Last edit: stan cartwright 2020-09-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you very much @evanvennn, @stan, @mkstevo.
After much trial and error, I changed all the rows and columns of the keypad to a single port (Port D) and used the "Keypad Port" method instead. I changed the LCD screen used and also had to erase the microcontroller before rewriting to it. I think that helped. I can now get input from the keypad to show on the screen.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please I need some help.
I am using a 4*4 matrix keypad and I just did the setup on hardware and I need to test if it works but it didn't.
I used the keypad test code in the keypad solutions folder and edited the ports to mine. I connected pull-ups to my columns also.
For output, I'm using a 16*4 LCD.
My rows and columns are not organized due to pin availability. I have them as such:
Row 1 portd. 7
Row 2 portd. 6
Row 3 portd. 5
Row 4 portd. 4
Column 1 portc. 5
Column 2 portc. 4
Column 3 portd.3
Column 4 portd.2
Could that be my problem??
Got some code to share?
Sorry I couldn't reply in time. I used my phone to make the first post.
Here's the code....
OK. That is code that should work.
Post a photo of the keypad, and, a photo of the setup/connection to the PIC
Okay, here's a snip of the circuit on proteus and a picture of the keypad used.
In the circuit, I used a 4 by 3 keypad because I could not find a 4 by 4 and for the column not used, I pulled it up according to the GCB manual.
Last edit: Judah Ben 2020-08-18
I am not sure what the issue is. Have you tried on real hardware?
Yes I have. The behaviour is the same. I'll still have to go over it today to try to figure out if there's an error somewhere.
Is the problem the keyboard or the display?
I think it's the keypad.
The display works fine with displaying whatever I give it in the code.
If it's the keypad, shouldn't the Proteus simulation work? On the hardware, it could be that your pullup resistors are too low in value. Have you tried measuring the resistance(s) of the switch buttons when pressed? on some of these carbon print membrane keypads the contact resistance could be quite high, not the near zero ohms you might expect with a traditional switch contact.
Sorry for this delay. I've been ill for some time.
I'm not really sure why it isn't working.
In the simulation, since I couldn't find a 4 by 4 keypad among the component parts, I used a 4 by 3 and then pulled up the empty column. (I thought this would suffice because I saw in the manual where they said if you're using a 3 by 3 keypad, pull up the unused row and column)
The resistance of each button is roughly 23 ohms.
You show a photo of a 4x4 keyboard. Why did you not use that as the demos are for 4x4 keyboards?
would changing c4 and c5 to rd0 and rd1 help?
Very sorry for the delay.
I couldn't find a 4 by 4 keypad among the component parts in proteus, I used a 4 by 3 and then pulled up the empty column. (I thought would work, from the manual)
Okay, let me make the pin changes and get back ASAP
There are 4 gcb keyboard demos that send to terminal and guess are working but not tried them.
so I guess this is for a 4x4 keypad cos I can't see where KeypadData is defined or dimmed.
looks like a keyword for a 4x4 keypad. Dunno.sorry.
shouldn't make a difference though. maybe you are using wrong port pins.
Last edit: stan cartwright 2020-09-01
Thank you very much @evanvennn, @stan, @mkstevo.
After much trial and error, I changed all the rows and columns of the keypad to a single port (Port D) and used the "Keypad Port" method instead. I changed the LCD screen used and also had to erase the microcontroller before rewriting to it. I think that helped. I can now get input from the keypad to show on the screen.