How can I get "Button" workspace value to hold and be stred in a portion of scr
Capt. Quirk
Posts: 872
The "workspace" value keeps resetting back to zero, every time I release the button. (like it supposed to, I am trying to save the value before it resets)
I am using a BS2p-40 and the AUX i/o pins to monitor four buttons on my PDB.
I am trying to enter a number that represents·kilograms. Then store the·number in my scratchpad ram and incorporate it into my program. I have read the manual and Dr Tracey Allen's site. The commands work fine for branching, but if it can "auto-repeat" I need to save that value.
Any suggestions would be helpful
Thanks
Bill
Post Edited (Capt. Quirk) : 8/31/2009 3:32:20 AM GMT
I am using a BS2p-40 and the AUX i/o pins to monitor four buttons on my PDB.
I am trying to enter a number that represents·kilograms. Then store the·number in my scratchpad ram and incorporate it into my program. I have read the manual and Dr Tracey Allen's site. The commands work fine for branching, but if it can "auto-repeat" I need to save that value.
Any suggestions would be helpful
Thanks
Bill
Post Edited (Capt. Quirk) : 8/31/2009 3:32:20 AM GMT
Comments
I would much rather the program look more like this, and be able to PUT "w" into ScratchPad ram
I think I would be better to Not use Button at all, and reduce it to this:
Post Edited (Capt. Quirk) : 9/1/2009 5:40:10 PM GMT
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]
When I want do this
DO
· BUTTON Button, 0, 225, 255, w, 1, Menu_Mass
· BUTTON Button, 0, 255, 255, w, 1, Menu_Humidity
· BUTTON Button, 0, 255, 255, w, 1, Menu_BarrometricPressure
· BUTTON Button, 0, 255, 255, w, 1, Menu_Main LOOP UNTIL i = -10
Why not try this
' {$STAMP BS2}
' {$PBASIC 2.5}
PickOne:
DO
IF IN1 = 1 THEN
gosub Menu_Mass
ELSE
IF IN2 = 1 THEN
GOSUB Menu_Humidity
ELSE
IF IN3 = 1 THEN
GOSUB Menu_BarrometricPressure
ELSE
IF IN3 = 1 THEN
GOSUB Menu_Main
ENDIF
ENDIF
ENDIF
ENDIF
LOOP
Menu_Mass:
DO
' your code
LOOP
RETURN
Menu_Humidity:
DO
LOOP
RETURN
Menu_BarrometricPressure:
DO
LOOP
RETURN
Menu_Main:
DO
LOOP
RETURN
OR this
' {$STAMP BS2}
' {$PBASIC 2.5}
BT1·· PIN· 1
BT2·· PIN· 2
BT3·· PIN· 3
BT4·· PIN· 4
cntr· VAR Byte··························· · '· VAR To a word
'· cntr = cntr + 1 * BT1················ ·' >> This one is used IF the OUTPUT = 1
'· IF (cntr = 300) THEN EXIT
'
'· cntr = cntr + 1 * (1 - BT1)········· ·' >> This one is used if the output = 0
'· IF (cntr = 300) THEN EXIT
PickOne:
·DO
cntr = cntr + 1 * BT1
IF (cntr = 10) THEN
GOSUB Menu_Mass
ELSE
·cntr = cntr + 1 * BT2
· IF (cntr = 10) THEN
GOSUB Menu_Humidity
ELSE
·cntr = cntr + 1 * BT3
· IF (cntr = 10) THEN
GOSUB Menu_BarrometricPressure
ELSE
·cntr = cntr + 1 * BT1
· IF (cntr = 10) THEN
GOSUB Menu_Main
ENDIF
ENDIF
ENDIF
ENDIF
LOOP
Menu_Mass:
DO
' your code
LOOP
RETURN
Menu_Humidity:
DO
LOOP
RETURN
Menu_BarrometricPressure:
DO
LOOP
RETURN
Menu_Main:
DO
LOOP
RETURN
The second one is different in that you set how long you must hold the button before it goes to which every routine you want it to
which is the CNTR = time that you want in loops
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:25:24 AM GMT