Why does does Do.. Loop does not execute in an infinite loop.
tucows
Posts: 4
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.
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
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
{$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
Also ...
And, last but not least, tucows ... welcome to the forum!
-Phil
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.
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.