If Key_pressed
Hello, I need help with a command that I am not sure what the name is.
What I want it to do is when I press a key it will follow the statement/command that I have it do.
I am using pBasic 2.5 and Bs2.
Thanks
What I want it to do is when I press a key it will follow the statement/command that I have it do.
I am using pBasic 2.5 and Bs2.
Thanks
Comments
Could I get a more specific answer?
Also could I get some syntax?
I took the code from the digital potentiometer in the Parallax book "Whats a micro controller?" on page 273-274.
What I want it to do is increase when Q is pressed here is the example code that would be nice if i had the correct command and the syntax
If Key_Pressed(This is the command I need) "Q"(The preferred key)
THEN newtapsetting = oldtapsetting +1
Lets try doing this with math or something simple before I try to use it in any complex way.
Lets say I want any letter of the alphabet to add 1 to the current value every time I press that letter.
It would look like something like this..
X VAR BYTE
X = 0
DEBUGIN temp
If temp = "Q" THEN X = X + 1
...Right?
I'm not sure how to make it so the board knows when I am pressing a key.
I would think that you could make the board read through hexidecimal values of keys or something.
You could attach a couple of pushbuttons to Stamp I/O pins or a 4 x 4 keypad and the Stamp could scan that. The reason that would work is that the Stamp program could probably check to see if one of the buttons is pressed several times a second and you would hold down the button typically longer than that. There are examples of this in the "What's a Microcontroller?" tutorial and some of the Nuts and Volts Columns, both downloadable from Parallax.
You can easily read decimal or hexadecimal values from the PC, but the Stamp has to wait for the characters to be typed. Look at the documentation on the DEBUGIN statement for examples, but the following will wait for characters to be entered, ignore any leading non-digits, accept a decimal number, and stop when the first non-digit is typed after the number.
DEBUGIN DEC temp
You can use the DEBUG statement to prompt the user like this:
DEBUG "Enter a value "
DEBUGIN DEC temp
Now my question is:
Is there any way to read this?
Example : If I press x is there any way to do this:
If text = x then...?
I get an error that says "expected a variable"
temp being the highlighted error.