Shop OBEX P1 Docs P2 Docs Learn Events
Why does does Do.. Loop does not execute in an infinite loop. — Parallax Forums

Why does does Do.. Loop does not execute in an infinite loop.

tucowstucows Posts: 4
edited 2012-07-01 10:05 in BASIC Stamp
I recently bought BASIC Stamp Activity Kit - Serial + USB (#90005). I am at very beginner level and started working on chapter 1 of the micro-controller book, LED lighting.

I have the following set of code to run :

DO

HIGH 14
PAUSE 500
LOW 14
PAUSE 500

LOOP

I ran the program and loaded it to the BS2 kit. However, when I run the program by pressing the switch, it just runs only one time. I am thinking the DO, LOOP should run infinitely ?
Why it just runs only one time ?

Experts out there... Please help me here.

Comments

  • garyggaryg Posts: 420
    edited 2012-06-24 16:07
    Although I'm not an expert,
    It would appear to me that your Pause 500 is pretty short.
    I would place a pause 2000 or something like that and
    ad a debug statement after the loop to see if the program is only running one time
    or if the duration is just too short to see.

    Thats just my two cents worth.

    garyg
  • tucowstucows Posts: 4
    edited 2012-06-24 17:09
    Tried that too: and it did not help.

    {$STAMP BS2}
    ' {$PBASIC 2.0}
    DEBUG "THE LED CONNECTED TO P14 IS BLINKING"


    DO


    HIGH 14
    PAUSE 2000
    LOW 14
    PAUSE 2000


    LOOP


    DEBUG "END OF THE PROGRAM -- EXIT"


    I see the last debug EXIT debug statement executed after few seconds.


    Thanks
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-24 18:35
    Your PBASIC directive needs to read:
    ' {$PBASIC 2.5} 
    

    Also ...

    attachment.php?attachmentid=78421&d=1297987572

    And, last but not least, tucows ... welcome to the forum!

    -Phil
  • tucowstucows Posts: 4
    edited 2012-06-25 07:03
    Thanks you
  • tucowstucows Posts: 4
    edited 2012-07-01 09:21
    tucows wrote: »
    Thanks you

    Can someone please help. The simple program is not working and I lost confidence on Basic stamp2 product. I also created a support ticket and upload the video, screen shoot, program. I did not get any help from parallax support as well.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-01 10:05
    There's really not enough information to just tell you what to do. The books are correct, the examples work for others, the software (Stamp Editor) works properly, so the question is "what's different about what you're doing?".

    As Phil mentioned, you need to specify PBASIC 2.5 in addition to STAMP BS2. If you're using a 9V battery as a power source, the battery may be exhausted and the additional current load of the LED is enough to drop the battery voltage to where it won't power the Stamp, so it resets and the program will start over again. Maybe your wiring is incorrect. It's always helpful to draw a schematic based on your actual wiring ... tracing the connections yourself. It doesn't help to just copy the schematic in the book. We know that's correct. When copying source code, it's always better to use the [ code ] and [ /code ] brackets as shown in the thread that Phil referenced. The forum software removes excess spaces from your messages making code hard to follow, not so much with Stamp Basic code which is often not indented, but with Propeller code where indenting is critical.
Sign In or Register to comment.