Code help
MichelB
Posts: 154
Hi to all,
in the attached code, when an out of range temperature is entered the message is showed noticed that temperature is out of range but program continues to run, where is my error? Thanks in advance.
in the attached code, when an out of range temperature is entered the message is showed noticed that temperature is out of range but program continues to run, where is my error? Thanks in advance.
Comments
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Quit buying all those fixed voltage regulators, and·get an Adjustable Power Supply·for your projects!· Includes an LED testing terminal!
The program continues because you don't tell it to return to the beginning of the program. So even though it will tell you the number is out of range, it is programmed to continue through the code. One solution would be to use subroutines, for example:
Putting the main routine in a DO...LOOP ensures that the code will get another value each time the program receives a value that is out of the range of temperatures. Then, when the program receives a temperature that's in range, it continues to the "display_distance" subroutine (you can re-name them whatever you like) to get readings from the PING.
For more information on subroutines, look up "GOSUB" in the BASIC Stamp Syntax and Reference Manual.
Hope this helps!
Jessica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax, Inc.
Post Edited (Jessica Uelmen (Parallax)) : 6/1/2009 4:50:26 PM GMT