Do-loop problem
manson
Posts: 3
I'm using BasicStamp, connected to my Board of Education with a serial cable,·to execute the following code:
'What's a Microcontroller - LedOnOff.bs2
'Turn an LED on and off. Repeat 1 time per second indefinitely.
'{$STAMP BS2}
·DEBUG "The LED connected to Pin 14 is blinking!"
DO
·HIGH 14
·PAUSE 500
·LOW 14
·PAUSE 500
LOOP
The LED is supposed to blind continuously. However, it blinked on and off only once and then stopped. Someone told me that it's my serial cable's problem, and as long as I add the line "DEBUG "Program Running!"", the LED should be able to blind continuously. But it didn't work... What might be the problem?
'What's a Microcontroller - LedOnOff.bs2
'Turn an LED on and off. Repeat 1 time per second indefinitely.
'{$STAMP BS2}
·DEBUG "The LED connected to Pin 14 is blinking!"
DO
·HIGH 14
·PAUSE 500
·LOW 14
·PAUSE 500
LOOP
The LED is supposed to blind continuously. However, it blinked on and off only once and then stopped. Someone told me that it's my serial cable's problem, and as long as I add the line "DEBUG "Program Running!"", the LED should be able to blind continuously. But it didn't work... What might be the problem?
Comments
Try it again after adding the following directive right after the $STAMP BS2 directive:
{$PBASIC 2.5} . The DO/LOOP construct is only available in PBASIC 2.5 and not before.
Regards,
Bruce Bates
I tried to add that comment. But the following error message pop up:
"Error - 154 Expected a directive"
I'm not sure if it's the problem with my program, or my BOE...
Thanks,
Manson
I tried to add that comment. But the following error message pop up:
"Error - 154 Expected a directive"
I'm not sure if it's the problem with my program, or my BOE...
Thanks,
Manson
Look at that directive carefully. There are CURLEY brackets surrounding it. Also, I apologize for not adding the leading quote mark. It should be entered like this:
'{$PBASIC 2.5}
You should be able to cut-and-paste that right from above, and place it right into your program. I just ran it through the Stamp Editor, and it appears to work fine.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
If the culprit is an oddball serial port design in your computer, the DEBUG command should keep the serial port open and prevent it from incorrectly sending a break condition to the BASIC Stamp.· I usually just use DEBUG CLS.· If there is no DEBUG command, another way to get the program to run is to unplug the Board of Education from the serial cable after you have downloaded the program.· Then, press and release the reset button.·
Also, when you insert the $PBASIC and $STAMP directives into your code, use the buttons toolbar in your BASIC Stamp Editor.· There's a button with a 2.5 in front of a gear for the PPASIC 2.5 directive, and a green BASIC Stamp·icon for the BASIC Stamp 2.·