Button short or long press
Hi, I have a button on pin 0 that need to have the following behavior: When short press (0,2 second) it must set out 8 high
When long press (1 or more second) it must set out 9 high
I can not solve this problem
Someone have a solution ?
Thank You very mutch.
When long press (1 or more second) it must set out 9 high
I can not solve this problem
Someone have a solution ?
Thank You very mutch.

Comments
Get_Button: btimer = 0 IF (TrButton = 0) THEN Get_Button DO WHILE (TrButton = 1) PAUSE 100 btimer = btimer + 1 LOOP RETURNThe value in btimer will tell you how long the button was held -- you can dictate what logic to apply from there. Note that this subroutine blocks the program until the button is pressed.
http://www.digikey.com/Web%20Export/Supplier%20Content/Parallax_149/PDF/Parallax_AppliedSensorsGuide.pdf?redirected=1
I'll try to inplement your suggestion in my project.
Main: ' stuff happens... B=0 DO WHILE pReadButton = 0 PAUSE 250 B=B+1 LOOP SELECT B CASE 1 ' quick press (< 250ms) CASE >19 ' 5 seconds CASE >3 ' one second ENDSELECT ' other stuff happens... goto Main