Problems in programming the EB-500!
Future_Engineer
Posts: 25
Hi there,
I need some help here..
I am working with the EB-500 controlled by the BS2 for a project, I wrote a program to turn ON the LED using the HyperTerminal by typing the letter "a", actually it worked, but I found out that the LED turn ON when I type any letter, also I've tried to turn OFF the LED by typing another letter but it didn't work since when I type anything it just turn it ON..
what should I do? anyone can help me or correct my mistakes?
if needed, I'll write down the program that I've wrote!
thank you very much in advanced!
PS: I've attached the program, its just to turn ON the LED, because the other program is in the school's PC.
Post Edited (Engineer_4ever) : 2/26/2008 5:45:32 PM GMT
I need some help here..
I am working with the EB-500 controlled by the BS2 for a project, I wrote a program to turn ON the LED using the HyperTerminal by typing the letter "a", actually it worked, but I found out that the LED turn ON when I type any letter, also I've tried to turn OFF the LED by typing another letter but it didn't work since when I type anything it just turn it ON..
what should I do? anyone can help me or correct my mistakes?
if needed, I'll write down the program that I've wrote!
thank you very much in advanced!
PS: I've attached the program, its just to turn ON the LED, because the other program is in the school's PC.
Post Edited (Engineer_4ever) : 2/26/2008 5:45:32 PM GMT
Comments
You can do that with the "edit reply" button (the little pencil).
I did what you told me to do!
Your program does exactly what it is programmed to do. You’re main routine is falling into the LED routine and turning it on before it ever checks the condition to see what character was received. You will need to reorganize the code such that the HIGH 9 occurs inside the conditional block.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thank you..
I'm sorry for asking for more, but its my first time to use and write a program in BS, and I need to know this thing "for testing only" to write another program for another project am doing..
I don't know all the commands but I'm trying my best to learn them ASAP!
so, my question now is, how should I reorganize the code?
Thanks again!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
As to your other question, I don’t know what you are asking…szData is just a variable you’re using to get a byte from the sender. You could call it anything you want. You could even set it to an ACK or NAK value and send it back to the sender to acknowledge the transmission. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Which you originally HAD specified 'szData' as an Array of Byte, but then changed it to a Word variable.
· Here's a fix for you:
'{$STAMP BS2}
' {$PBASIC 2.5}
'szData VAR Byte(20)
· szData VAR Byte
· LEDPin CON 9
· 'Wait for the eb500 radio to be ready
· PAUSE 1000
Main:
· SERIN 16,84,[noparse][[/noparse]szData]····· ' MOD -- Wait here for a character to be recieved.
· SEROUT 16,84,[noparse][[/noparse]szData]
· GOSUB LED··················· ' MOD
GOTO MAIN·····················' MOD
LED:
· IF szData = "a" THEN
··· HIGH LEDPin
· ELSE
··· LOW LEDPin
· ENDIF
RETURN
Note "SERIN 16..." uses the DB-9 programming connection to your PC.
Note "LED:" is now a subroutine, which turns ON the LEDPin if an 'a' is recieved, or
turns OFF the LEDPin if any other character is recieved.
allanlane5, thank you so much for correcting my program, I've tried it and it worked!
another question, "sorry am asking so much" after I tested the program I thought about using more than one letter to HIGH the LED, so, I have to change "szData VAR Byte" to "szData VAR Word", right? and what about connecting the EB-500 to a smart phone?
"I hope I can finished the project soon to share it in the Completed Project section"
or:
MyVal VAR WORD
...
SERIN 16, 84, [noparse][[/noparse]DEC MyVal]
SEROUT 16, 84, [noparse][[/noparse]DEC MyVal, CR]
...
LED:
IF MyVal = 10 THEN
HIGH LEDPin
ELSE
LOW LEDPin
ENDIF
RETURN
thanks again!
edit:
I've tried it, but it didnt work!
what is DEC?
also, when I tried to run the program it says "No BASIC Stamp found", why? everything is connected!
and when I ran the previous program, it didn't work when I type anything!
Post Edited (Engineer_4ever) : 2/27/2008 6:52:06 PM GMT
2. The "DEC" is a "Modifier" for SERIN/SEROUT that says "Don't send (or recieve) the literal value, instead send (or recieve) an ASCII translated version of the value". You can read about it in the help file under SEROUT.
So, what's an "Ascii translated version"? Say you have a number, like 10. Now, that number can be a VALUE stored in a memory location or register, the VALUE 10. That number can be converted into an ASCII string, which consists of 2 bytes, the byte "1" (CHR(49)) followed by the byte "0" (CHR(48)).
You COULD send the VALUE 10, and to VB it would look like CHR(10) (which is a newline in ASCII). It's easier to send "1" "0" <CR> using Hyperterm, so that's why I suggested the DEC modifier, which does all this "ascii translation" for you.
I found out that the reason why I kept having a "no basic stamp found" is the low power, and I've fixed it!
Well, right I didn't understad everything, but there is a program in my mind I want to try it first, if it didn't work, i'll write down the program here for checking "if no one mind", and if it is not good, I'll get back on that and work on it!
I've got a question.
I want to do increment using IF...THEN command, how to do it?
The simple answer is you don't. You increment a counter (X = X + 1) outside of the IF...THEN statement. Here is an example:
··· IF variable = value THEN Bypass
··· X·= X + 1
Bypass:
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Genius is one percent inspiration and ninety-nine percent perspiration."
Thomas Alva Edison
Post Edited (Bruce Bates) : 2/29/2008 5:31:41 PM GMT
so, can I do:
IF variable1 = value1 THEN
x = x + 1
ENDIF
IF variable2 = value2 THEN
x = x + 1
ENDIF
IF x = 2 THEN
HIGH .......
?
anyway, thanks Bruce Bates..
can someone please tell me what's wrong in this program? It's not working!
I wrote this program to be like checking·a password, but somehow it's not working!
Thank you!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the oacen of Electronic Engineering~
In what way is the program not working? You'll have to provide a better description of what's wrong, if you'd like help in troubleshooting the problem.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Genius is one percent inspiration and ninety-nine percent perspiration."
Thomas Alva Edison
The error message I got is telling me this:
"Lable is missing ':' "
and the "Y" in the program is shaded. I don't know why!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the oacen of Electronic Engineering~
··· Y = Y + 1
It's because you haven't declared Y as a variable.
But, when I run it, and tried to test it in HyperTerminal, it didn't work!
I wanted to turn ON the LED after I type the word "hello" and if I made any mistake in typing the word, it should give me a chance for 3 times only to re-enter the word!
Anyone can help?
Here is the corrected·program!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~Swimming in·the oacen of Electronic Engineering~
The most obvious problem I saw was that you have:
GOSUB repeat
in your program, and the is no RETURN command anywhere in the program. If you use GOSUB, there MUST be a RETURN statement. They are always used in pairs.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Genius is one percent inspiration and ninety-nine percent perspiration."
Thomas Alva Edison
[noparse][[/noparse] That should be ocean, not "oacen" ]