Variable Questions
railroad signal
Posts: 5
Hello everybody.
I am trying to understand variables. What I am trying to accomplish.When I momentarily push a button I would like to register that the push buttonhas or has not been pressed in the DEBUG HOME. I am having problems. Cannot getthe input to communicate with the variable. What is your recommendations. Thank you.
' {$STAMP BS2}' {$PBASIC 2.5}
hold VAR Bit
DO
DEBUG HOME
DEBUG ? IN0
DEBUG ? hold
INPUT 0
LOOP
I am trying to understand variables. What I am trying to accomplish.When I momentarily push a button I would like to register that the push buttonhas or has not been pressed in the DEBUG HOME. I am having problems. Cannot getthe input to communicate with the variable. What is your recommendations. Thank you.
' {$STAMP BS2}' {$PBASIC 2.5}
hold VAR Bit
DO
DEBUG HOME
DEBUG ? IN0
DEBUG ? hold
INPUT 0
LOOP
Comments
The program looks okay. The variable "hold" doesn't do anything. A simpler test program is,
DO
DEBUG in0+48 ' prints 0 or 1
PAUSE 100
LOOP
That simply shows a continuous line, 00000011111100000011...
But if your input is normally HIGH and goes LOW when you press the button, then use this:
Once you press the button, hold will retain the state. You will need to clear/reset hold later in your program to capture another button press.