Hi, I have really tried for a while but no sucess
I want to use a button, and when you press the button for 1.5 sec, it will do something else it will do a different thing.
so a button with the delay of 1.5 sec
Thanks!
Delay button
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Delay button
Hello
Ok you will need to the following inside your main loop.
1. Read the switch in question into a variable.
2. Test the variable using a decision.
3a. If the variable is set then wait 1 second and 500 milli seconds
3b. read the switch again into the variable
3c. Test the variable again if it is still set then the button has been pushed for long enough, now you can jump to your macro or set a variable with a value etc to indicate the successful detection.
4. else do nothing
If you want a better program then you could use a loop with a smaller delay and reckeck that the button is still pressed more then once. For example you could check 150 times within the second and a half using 10ms delays. If the count that is returned at the end is 150 then you know that the button was held down the entire time.
Hope this helps.
Ok you will need to the following inside your main loop.
1. Read the switch in question into a variable.
2. Test the variable using a decision.
3a. If the variable is set then wait 1 second and 500 milli seconds
3b. read the switch again into the variable
3c. Test the variable again if it is still set then the button has been pushed for long enough, now you can jump to your macro or set a variable with a value etc to indicate the successful detection.
4. else do nothing
If you want a better program then you could use a loop with a smaller delay and reckeck that the button is still pressed more then once. For example you could check 150 times within the second and a half using 10ms delays. If the count that is returned at the end is 150 then you know that the button was held down the entire time.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel