??? 04/04/06 10:22 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#113598 - if its roundrobin Responding to: ???'s previous message |
if you are using some round robin machanism then in between your running loop you can just poll the pin connected to the switch and if that is pressed(i,e 0)increase a counter variable by 1 and after this check if this overflow a fix value X,if yes then increment the display count.if the pin is high then simply reset the counter varriable.the fix value X is to be choosen by some hit-trial,and that also depends on the length of round robin loop.
>> main() while(1) { //........some task code //........some task code //........some task code if(button1 == 0){ count_var++; }else{ count_var = 0; } if(count_var1 > scan_delay) { // then increment the count value } //........some task code if(button2 == 0){ count_var++; }else{ count_var = 0; } if(count_var2 > scan_delay) { // then increment the count value } //........some task code if(button3 == 0){ count_var++; }else{ count_var = 0; } if(count_var3 > scan_delay) { // then increment the count value } //........some task code //........some task code } in above code you will have to tweak the value of scan_delay constant as per human behaviour so that even a single key press can be detected...actually i tried above scheme in one of my project and it worked well . note>> for getting more precision try putting the above code inside a timer interrupt handler configured to fire at 500 microseconds. |
Topic | Author | Date |
LCD repeat function in C | 01/01/70 00:00 | |
First thought | 01/01/70 00:00 | |
if its roundrobin | 01/01/70 00:00 | |
last post | 01/01/70 00:00 | |
Sounds fine | 01/01/70 00:00 | |
the one issue | 01/01/70 00:00 | |
stuck key | 01/01/70 00:00 | |
Yes | 01/01/70 00:00 | |
Code Review | 01/01/70 00:00 | |
this must be excellent switches | 01/01/70 00:00 | |
excellent debounce for bad switches![]() | 01/01/70 00:00 | |
better code version | 01/01/70 00:00 | |
no comments, captals, no indenting | 01/01/70 00:00 | |
It could do with some improvement! | 01/01/70 00:00 | |
I did not comment on that, it may very w | 01/01/70 00:00 | |
true.... | 01/01/70 00:00 | |
led to so much misinformation in this fo | 01/01/70 00:00 |