Does each instance of 'BUTTON' need a separate workspace?
cthomas
Posts: 17
Just wondering...I don't need to debounce my pushbuttons and am wondering about using multiple instances of BUTTON.
It's not clear from the command definition, if each BUTTON command needs it's own workspace or if 'workspace' could be shared.
It's not clear from the command definition, if each BUTTON command needs it's own workspace or if 'workspace' could be shared.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
Post Edited (Chris Savage (Parallax)) : 9/1/2009 8:19:22 PM GMT
I'm building a project and need to monitor 10 switches.
Is using 'BUTTON' not desirable in this case? I believe the PBASIC manual relates that each 'button worskspace' is a byte and so my approach would use 10 bytes of the 26 bytes of RAM available in a BS2.
If I'm not using more than 16 additional program variables, I should be ok in terms of RAM usage?
Yea/Nea?
Thanks,
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·
Program: SW21-EX14-Debounce.BS2· Page 95 of the Stamp Works book
But I will try this routine and see how this work I do now have a PDB
[/font][/font]I use switches in a lot of project·I have never use the button command
I ether use IN# what ever pin·I going to use and it works very well
IF IN0 = 1 THEN
GOSUB YourRoutine
ENDIF
or·I use these routine if I want the state to ether 1 or 0· for certain amount of time before it gose to what ever routine you want it to do
· · cntr = cntr + 1 * Chg·············· ·>> This one is used if the output = 1······· ·Chg is the pin that your switch is hook up to
·· IF (cntr = 10) THEN
GOSUB Your_Routine
ENDIF
· cntr = cntr + 1 * (1 - Chg)········ ·>> This one is used if the output = 0
· IF (cntr = 10) THEN
GOSUB Your_Routine
For me the button command dose not work for me in the project that I do
I hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 9/3/2009 1:23:19 AM GMT
Yes, you can use the 16 bytes if you choose and do not need them. The Stamp Works experiments I was referring to simply show another way to read the inputs at the same time, debounce and store them in a lot less space. One situation where it may be desirable to use the BUTTON command is if the duration of individual buttons changes certain program variables on the fly. For example, if you write a look for the BUTTON statement and DEBUG the work variable you will notice its value changes after some time when you hold the button down. This can be used to affect your program in a certain way. I have used it with a simple clock to make it so that holding the set button put the clock into set mode, but momentary presses were ignored. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
Understood - thank you.
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·