Probably this questions has been raised before, but I could not find the answer.
How do you test that 2 buttens are pressed at the same time. In practice, on short time scale, one button will be pressed before the other. Thus just a simple interrupt on change will not work.
Who can help me?
Kind regards
Jan Lichtenbelt
Press 2 buttons at the same time
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Press 2 buttons at the same time
On detect of either input, you could loop a fixed number of times, with a short delay in the loop, and count how many times each input is active. Outside the loop compare each count with a threshold value and make a decision as to whether you consider either or both pressed.
Although it assumes you have the time available to sit in the loop.
Hope that helps,
Leigh
Although it assumes you have the time available to sit in the loop.
Hope that helps,
Leigh
-
- Valued Contributor
- Posts: 1189
- Joined: Wed Dec 31, 2008 3:37 pm
- Has thanked: 460 times
- Been thanked: 523 times
Re: Press 2 buttons at the same time
Hi Jan
How about for example looking at port D and look at the entire port
button A on D4 button B on D5
button A would return 8 if the port was scanned button B would return 16
If button A & B where to be pressed then the port scan would return 24 (8 + 16)
Then you can make a decision on what to do biased upon the returned value
Steve
How about for example looking at port D and look at the entire port
button A on D4 button B on D5
button A would return 8 if the port was scanned button B would return 16
If button A & B where to be pressed then the port scan would return 24 (8 + 16)
Then you can make a decision on what to do biased upon the returned value
Steve
Success always occurs in private and failure in full view.
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Press 2 buttons at the same time
This (equivalent) flowcode works fine. I used first a delay of 10 msec, but that was to fast. Now the delay is 100 msec between testing the status of the buttons.
The same can be done by means of IOC instead of a while statement.
Kind regards
Jan
The same can be done by means of IOC instead of a while statement.
Kind regards
Jan