Is it not just? AND am I missing somthing?
Hello all,
I have to ask because I have NEVER seen it done any other way. But is it not just plain good design practice to current limit with series resistors and pull up or down ALL digital I/O's?
And as far as driving your 220AC device. You should ALWAYS use some sort of isolation device to protect your DC circuits AND the poor person that is trying to use them!
But back to the thread....
Tell me if I am missing something here and if this would work at all:
if doing a keypad scan could you not use portb 0-2 and portb 3-7 for a 3x4 keypad. then use a look up table to get the actual key pressed? If you could do this it would be easy to add "secret" key combinations to do special functions in the project.
I am just getting started here and learning lots by reading. I have spent quite some time looking over the Keypad code posted here and its VERY complex more so then I would have thought. am I missing something here?
(I am not saying anything bad about the code. I could just be ignorant to what it takes to actually do this. So please don't be insulted.)
Also, I see no accomidation in the keypad for compairing the input from the keypad to stored values for say "pin access" or the such. Or is this code ment to be only the keyscan?
Just asking?
;Smart A** Programing Joke starts here
cls
Print "Best Regards,"
Print "Bill12780"
end
Scanning Many Keys With One Input
Hi charudatt,
Quote:
Originally Posted by
charudatt
Hello,
I remember seeing an idea of connecting multiple (more than 1) switches on a single Port(analog) pin and working with the adc val.
Cannot find this anymore on the forum.
Any help on this topic/idea.
regards
TIP #5 Scanning Many Keys With One Input
EDIT: TIP #7 4x4 Keyboard with 1 Input
Microchip’s Tips ‘n Tricks (DS40040C)
http://ww1.microchip.com/downloads/e...Doc/40040C.pdf
Hope this helps,
-Adam-
problem with serout and keypad routin Mister_E
Hi Steve,
Some time ago you modified your code for pbp243 (if you remember)
Meanwhile I have updated to 2.50
After playing with your code I have a strange behavior
If I want to serout something in the main loop it is not working
any idea how to fix this
INCLUDE "KeyPad.bas"
myvar var byte
start:
Hserout ["test",10,13] 'does not do anything
@ READKEYPAD _myvar
hserout ["Key=",dec myvar,13,10]
if myvar =1 then
Hserout ["test2",10,13] 'does work if button 1 pressed
endif
goto start
Quote:
Originally Posted by
mister_e
Here's a simple INCLUDE file wich allow to scan any matrix KeyPad format on any PORT you decide. Yeah i know, a bit code hungry but simple to use and it's free...
The defaults setings are
- Keypad ROW are connected to PORTB<3:0>
- Keypad COL are connected to PORTB<7:4>
- Debounce delay = 200 mSec
- No auto-repeat
- Keypad type 4X4
Code example using the default setting
Code:
INCLUDE "KeyPad.bas"
myvar var byte
start:
@ READKEYPAD _myvar
hserout ["Key=",dec myvar,13,10]
goto start
NOT MUCH!
If you decide to change default settings, here's the DEFINEs list
Code:
DEFINE KEYPAD_ROW 4 ' 4 ROW keypad
DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB
DEFINE KEYPAD_ROW_BIT 4 ' ROW0 = PORTB.4
DEFINE KEYPAD_COL 4 ' 4 COL keypad
DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0
DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec
DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature
When using the auto-repeat feature, the delay is the debounce delay (DEBOUNCEMS)
Code example #2: Using a 8X4 keypad
Code:
INCLUDE "KeyPad.bas"
'
' Hardware connection
' ===================
DEFINE KEYPAD_ROW 8 ' 8 row
define KEYPAD_ROW_PORT PORTB ' on PORTB
DEFINE KEYPAD_ROW_BIT 0 ' <7:0>
DEFINE KEYPAD_COL 4 ' 4 col
DEFINE KEYPAD_COL_PORT PORTA ' on PORTA
DEFINE KEYPAD_COL_BIT 0 ' <3:0>
DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec
define KEYPAD_AUTOREPEAT 1 ' use auto-repeat
'
' Serial Communication definition
' ===============================
DEFINE HSER_TXSTA 24h ' enable transmit, BRGH=1
DEFINE HSER_SPBRG 129 ' 9600 Bauds
'
' Variables definition
' ===================
myvar var byte
' ---------------------------------[Program Start]----------------------------------------------
start:
@ READKEYPAD _myvar
hserout ["Key=",dec myvar,13,10]
goto start
It set the according TRIS register for you everytime you call the MACRO.. kinda bullet-proof
Everything is explain in the attach file... don't forget to rename it :)
Optional timeout keyboard routine
Hi MisterE
Using with succes your keypadroutine on a 4x2 keypad
I was wondering if it would be possible to jump out the keypadroutine if no key is pressed
in order to handle the main loop
I need to receive some serial commands by HSERIN, but when a key is pressed
it should go to a label and then return to the main loop checking Hserin
Now it waits for a keypress
Thanks