Scanner Input
R0y4L
Posts: 23
Hello all Javelin geeks [noparse]:)[/noparse] hehehe
I just got my Javelin Stamp and tryint to familiarise myself with it. I have to say its very different from Basic Stamp. I would like to know is there a way of getting user's input? I have worked out myself that Scanner class does not work. lol.
Oh yeah and another thing. Where could I find information about all classes and all imports that are available for Javelin Stamp cause I'd like to control my servos somehow.
Thank you all
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
I just got my Javelin Stamp and tryint to familiarise myself with it. I have to say its very different from Basic Stamp. I would like to know is there a way of getting user's input? I have worked out myself that Scanner class does not work. lol.
Oh yeah and another thing. Where could I find information about all classes and all imports that are available for Javelin Stamp cause I'd like to control my servos somehow.
Thank you all
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
Comments
Virtual Peripherals (including PWM for servo control).
To get input you can use Terminal.getChar().
Most used import classes are in the core folder, use
import stamp.core.*;
regards peter
much appreciated.
Reads characters and converts them to uppercase. Remember that the messages from
Javelin window can be used for bi-directional communication. After running Program Listing 3.11, simply click the
transmit terminal. Next, try typing a few characters. The characters will appear in the transmit terminal, and they will
also be echoed in the messages window above. Immediately after each echoed character, you will also see the Javelin
Stamp’s converted character.
import stamp.core.*;
public class Capitalize {
public static void main() {
char c;
System.out.println("Begin");
do {
c=Terminal.getChar(); // Get character from keyboard
if (c>='a' && c<='z') { // Test if it’s not a capital
int tmp=(int)c; // Create and assign ‘tmp’ the char c as an int
tmp=tmp-32; // Convert lower case to upper by subtracting 32
c=(char)tmp; // Assign int tmp into char c
} // end if
System.out.print(c); // Output character
} while (c!=27); // Do the above until escape key is pressed
} // end main
} // end Capitalize
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit: www.vbnoobs.co.uk
http://forums.parallax.com/showthread.php?p=656527
You must type characters in the 1 line send text field. If you type in the
large terminal window, nothing is sent to the javelin.
Also, better to use Enter (Carriage return) rather than ESC.
I am not sure ESC gets transmitted, but CR is (test for CR [noparse][[/noparse]0x0D]·or LF [noparse][[/noparse]0x0A]).
It may be that CR gets translated to newline (which is 0x0A).
regards peter