PDA

View Full Version : 3x4 matrix keypad



tazntex
- 14th October 2008, 03:40
I have looked at the 16-key serial keypad example from Bruce's website to try and understand how to make my pic scan the keypad. I have a 12 key pad that the column are set up to connect to my 16f628a on B0-B-2 and the rows will connect to B3-B6. That leaves me with B7 set as an input and pulled 5v high with a 10k resistor. I have been trying to modify the code to work with no sucess. Does anyone have any suggestion on what I may be doing wrong. Thanks

BTW: I am trying to insert a code block instead of just copying and paste to the forum so hopefully this works.

Darrel Taylor
- 14th October 2008, 08:55
Going with Bruce's code is always a good bet.

But on this one, mister_e might have the right ticket for you.

Variable sized keypads ...

Matrix Keypad routine
http://www.picbasic.co.uk/forum/showthread.php?t=3250
<br>

tazntex
- 14th October 2008, 15:33
Thanks Darrel for the reply, I finally have Bruce's code working with some modifications. I am still using portb.0-2 for my rows and portb.3-6 for my columns and portb.7 is not used so I have made it an input and pulled high via a 10k resistor. Reading my keys for what KEY value actually is in decimal, I have 1-11 buttons on this keypad, the values are 1,2,3,4,5,7,8,9,10,11,12. I don't quite understand how I missed 6 but its working good. Now for my real question, would you recommend how I may make the key being pressed continually be transmitted while I am pushing it and stop when I release the key? I have attached a text file of the code I have modified you will see under my mods Bruce's original code. Thanks again

tazntex
- 14th October 2008, 20:13
I think I figured out how, I just added an IF ((PORTB >> 3) !=1f) then send at the beginning of label getkeyu.

Seems to be working ok momentary, now I just have to figured out how to use NAP to let the pic sleep in between button presses.

Back to the PBP manual......

Thank you for you suggestions.