Shop OBEX P1 Docs P2 Docs Learn Events
Do-loop problem — Parallax Forums

Do-loop problem

mansonmanson Posts: 3
edited 2004-11-12 16:34 in BASIC Stamp
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?

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-12 06:48
    Manson -

    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
  • mansonmanson Posts: 3
    edited 2004-11-12 06:53
    Hi Bruce,

    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
  • mansonmanson Posts: 3
    edited 2004-11-12 06:56
    Hi Bruce,

    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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2004-11-12 07:14
    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 WilliamsJon Williams Posts: 6,491
    edited 2004-11-12 14:53
    Remember that the BASIC Stamp IDE has buttons right on the toolbar for setting the Stamp module, and language version.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • edited 2004-11-12 16:34
    Try copying and pasting the code below into your editor; then run the program.·
    'What's a Microcontroller - LedOnOff.bs2
    'Turn an LED on and off.  Repeat 1 time per second indefinitely.
     
    '{$STAMP BS2}
    '{$PBASIC 2.5}
     
    DEBUG "The LED connected to Pin 14 is blinking!"
     
    DO
     
      HIGH 14
      PAUSE 500
      LOW 14
      PAUSE 500
     
    LOOP
    
    

    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.·
Sign In or Register to comment.