View previous topic :: View next topic |
Author |
Message |
JPH
Joined: 02 Feb 2005 Posts: 9 Location: Finland
|
multi operation button |
Posted: Sun Nov 20, 2005 12:09 pm |
|
|
Hello
I have connected buttons to RB4:RB5 pins and I like to use RB4 two different operations. Low time<1s reset function and low time>1s sleep prosessor. I use #INT_RB to read buttons and handle state changes in my program code. Question is what would be the easiest way to read time, how long RB4 is on low state? So does someone have sample code, how should I do it.
cheers
Jussi |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sun Nov 20, 2005 1:18 pm |
|
|
Set up a timer to overfrlow every, say, 0.1s and count the number of interrupts n while the button is pressed. Stop counting when the button is released. If n<10 do something if n>10 do something esle. There is a lot of timer code listings in the forum. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Nov 20, 2005 8:22 pm |
|
|
Check out the code library |
|
|
JPH
Joined: 02 Feb 2005 Posts: 9 Location: Finland
|
|
Posted: Tue Nov 22, 2005 6:29 am |
|
|
thanks for the replies
But can someone give me a sample code, how it should be done?
I looked code library but I didn't find any simple example to manage many operations in single button.
-Jussi |
|
|
|