PDA

View Full Version : how to configure multi click in keypad



ilham M
- 21st May 2009, 11:02
hi every one

i have keypad with 12 buttons(1-9 ,#,*)

so

i need to read character from user

i think the idea is by making a short time loop for each input from the keypad for example 1sec. The purpose of the loop to count how many times you clicks the button within the 1 sec. if you click just once then it gives you a character for example (a) . if you press it twice then it gives you another character (b).


but i dont know how program it

any help plzzz

ilham M
- 22nd May 2009, 20:39
anybody here ??

i want just ahead for loop with time how can i write it??

Archangel
- 22nd May 2009, 23:02
As a new member to this forum, Welcome !
To get help here Usually (not always), requires some simple effort, in this case, look at the threads listed under " CODE EXAMPLES", and come back with your questions, after finding some nice example code, and chewing on it a while. There are some Tasty morsels in there.

ilham M
- 23rd May 2009, 19:56
really i didnt Expect reply like this
not because i expect every body hurry to help me
BUT
because
it is clear how much i thinked & searched in web


any way thank u so mush

:)

Archangel
- 23rd May 2009, 21:44
Not asking you to search the web, I am asking you to search this forum.
OK, I will take you by the hand, and lead you.
1. http://www.picbasic.co.uk/forum/forumdisplay.php?f=11 code examples link, click it.
2.http://www.picbasic.co.uk/forum/showthread.php?t=3250 Wow look what I found there ! A matrix key routine ! And it works too !
3.http://www.picbasic.co.uk/forum/showthread.php?t=6311 :eek: Another key routine ! Oh if only I had not gotten offended by Joe asking me to do something for myself !
4.http://www.picbasic.co.uk/forum/showthread.php?t=3487 What? Another one ? ! ! !
Look, God helps those who make an effort to help them selves, I am much inferior to God, so I really NEED you to make an effort. I stand by my original statement, I and everyone else will help you, but I will not come to your house and do it for you. You are Welcome here.

ilham M
- 24th May 2009, 19:52
:)

thank u joe for ur effort.

i read it before , and it is not answer my question

thank u again.

Archangel
- 24th May 2009, 20:15
:)

thank u joe for ur effort.

i read it before , and it is not answer my question

thank u again.

OK then tell us more about the problem, If I misunderstood what you are doing, please straighten me out. There is a table of abundance here, please do not go away hungry. Have you written some code that does not work ? If so please post it so we can see what you are trying to do.

Melanie
- 24th May 2009, 21:29
I think what iham wants is the kind of keypad entry you get with Mobile phone texting...

ie.. Button '2' is also A B or C...

So you press it once you get '2', you press it again within say 1 second, you get 'A', press again and you get 'B', and again you get 'C'... then back to '2' again, and so on. If you leave it more than 1 second, it remains with whatever the last selection was and moves to the next character position.

This really means integrating the Keypad with a Display... because you will be changing the displayed value depending if the same key is pressed again within the timeout period, and having an Array for storing the resultant Alphanumeric Text 'string'.

ilham M
- 25th May 2009, 19:16
I think what iham wants is the kind of keypad entry you get with Mobile phone texting...

ie.. Button '2' is also A B or C...

So you press it once you get '2', you press it again within say 1 second, you get 'A', press again and you get 'B', and again you get 'C'... then back to '2' again, and so on. If you leave it more than 1 second, it remains with whatever the last selection was and moves to the next character position.

This really means integrating the Keypad with a Display... because you will be changing the displayed value depending if the same key is pressed again within the timeout period, and having an Array for storing the resultant Alphanumeric Text 'string'.


exactly Melanie

in program how can i discrimination the time between presses ??

Melanie
- 26th May 2009, 00:28
There are many ways of doing this...

In the example appended (just to get you started), the Subroutine exits ONE SECOND after the Button has been pressed. If the Button is pressed within the one second period, a new value is assigned and the Counter is reset for one second again. Only when ONE Second has elapsed from the last Button press, will the subroutine exit with the key value.

This Subroutine assigns ASCII numeric 2, or alphabetic A, B or C to the Button.

You will have to expand this out across your entire keypad, and integrate LCD Display, but the principle remains the same. At the heart of this, we are simply counting 100 loops of 10mS each. 10mS is also a good debounce time, so it serves a dual purpose.


ButtonA var PortB.0

CounterA var BYTE
CounterB var BYTE


'
' Subroutine Assigns one of FOUR Characters 2,A,B,C when Button Pressed
' ---------------------------------------------------------------------
' CounterA = Number of Button Presses (0-4)
' CounterB = Number of 10mS Loops Executed
' also contains ASCII Character (or Zero) - on Exit
'
GetKey2ABC:
CounterA=0
CounterB=0
GetKey2ABCLoop:
If ButtonA=0 then
CounterA=CounterA+1
If CounterA>4 then CounterA=1
CounterB=0
While ButtonA=0
CounterB=CounterB+1
Pause 10
If CounterB>100 then goto GetKey2ABCExit
Wend
else
CounterB=CounterB+1
Pause 10
endif
If CounterB<100 then goto GetKey2ABCLoop
GetKey2ABCExit:
Lookup CounterA,[0,"2ABC"],CounterB
Return

ilham M
- 29th May 2009, 19:56
thank u very much Melanie
u give me the keys :)
i will try it and expand it inshallah