Freshman in Basic Stamp
philip88822
Posts: 11
Hello Everybody
I am a freshman in Basic Stamp and i want to know what is the code of the following question
Questions:
Display the message “ Please Key in S to start ” in the Debug Terminal and prompt the user to key in letter S.·· Display the message “ Wrong letter ” in the Debug Terminal and prompt the user to key in again when the input is not S.·· If the input is True , then display the message “ Right letter ” in the Debug Terminal.
Thx a lot
Philip
I am a freshman in Basic Stamp and i want to know what is the code of the following question
Questions:
Display the message “ Please Key in S to start ” in the Debug Terminal and prompt the user to key in letter S.·· Display the message “ Wrong letter ” in the Debug Terminal and prompt the user to key in again when the input is not S.·· If the input is True , then display the message “ Right letter ” in the Debug Terminal.
Thx a lot
Philip
Comments
Another good source for information is the "What's a Microcontroller?" tutorial. These can all be downloaded from Parallax. Go to their main webpage
and click on the Resources tab. You'll see a list of resources. Choose Downloads, then Stamps in Class Downloads to find the tutorials. From
Downloads, choose BASIC Stamp Documentation for a link to the Reference Manual.
This sounds like a project for a class and you need to do that yourself in order to learn properly.
But i want to know the correct code as i don;t know am i correct or not
Also, i want to ask is there any way to check out the program is work or not without the stamp?
Post Edited (philip88822) : 3/3/2009 3:38:38 PM GMT
I·have already download the DOC that you told me to download
But i am not·sure that i·understand or not
THANK YOU VERY MUCH
If English is not your native language, there are translations of both of these references also available on the same webpages I mentioned.
If you post the code you already have then I'm sure Mike, myself, or one of the other wonderful people who help others on these forums will be glad to
guide you into fixing your code.
You may attach your code by clicking Post Reply then using the Attachment manager to upload your code.
The things you need to research are:
Variables
IF statements
DEBUG command
DEBUGIN command
All the needed information on these are available in the Basic Stamp editor's helpfile and also in the "What's a Microcontroller" book. You can also find the
information in "Robotics with the BOE-Bot".
All of which are available as free downloads on the Parallax site. Go to www.Parallax.com and click on Support then Basic Stamp Documentation for the books
or Basic Stamp Software for the editor. As Mike said, there are several translations of the various books and several versions of the software for PC, Mac and
Linux.
You now have all of the information and direction needed to answer your question. If you need further help that does not involve someone doing your homework
for you, then feel free to ask.
Post Edited (Ugha) : 3/4/2009 3:55:16 AM GMT
MyNum VAR Nib<
What is the use of this?
DEBUG CLS, "Please Key in S to start"<----What is the meaning of CLS?
DEBUGIN DEC1 myNum<
IF ((myNum = S) THEN
DEBUG CLS, "Right Letter·"
ELSE
DEBUG CLS, "Wrong letter"
ENDIF
END
Is there anythings that i need to change?
Thx for help
·
"MyNum VAR Nib" tells the compiler to set aside (declare) space for a 4 bit value and give it a name "MyNum" for use elsewhere in the program.
In your case, you want to use a byte rather than a nibble because the values you will store (characters) are 8 bits.
"CLS" is a predefined name for a character that will clear the debug window when sent by a DEBUG or SEROUT statement to the debug window. There's a table in the manual of this and other predefined names. Read the chapter on the DEBUG statement for this.
"DEBUGIN DEC1 myNum" uses what's called a formatter (DEC1) to process the input characters from the debug window. There's a description of all the formatters in the chapter on the DEBUGIN statement and in Appendix C. If you don't use a formatter, the next character's ASCII code value is put into variable. In your case, that's probably what you want (leave out the DEC1).
The IF statement you wrote won't work for 2 reasons:
1) The parentheses are not balanced. You don't need them anyway.
2) You're comparing myNum to S and S isn't defined anywhere. As you've written it, it's a name just like myNum. You probably want to put quotes around it. Read the section of the manual on constants, expressions, and number representations (pages 94-98).
It's a lot to go through, but you really have to read through the "What's a Microcontroller?" tutorial and the introductory parts of the Stamp Manual.
Post Edited (Mike Green) : 3/4/2009 2:49:10 PM GMT
DIRB=15
DIRC=15
DIRD=15
OUTC=0
A VAR BYTE
MAIN:
A=0
DEBUG “PLEASE KEY IN S TO START!” , CR
SERIN 16,16468,[noparse][[/noparse]A]
IF A=”S” THEN CORRECT
IF NOT (A=”S”[noparse];)[/noparse] THEN INCORRECT
CORRECT:
DEBUG “RIGHT LETTER” ,CR
GOTO MAIN
INCORRECT:
DEBUG “Wrong Letter”
Goto main
How about this code
Does it work?
What you posted looks like it should do what you want