Shop OBEX P1 Docs P2 Docs Learn Events
Looping 7-Digit LED Display — Parallax Forums

Looping 7-Digit LED Display

edited 2013-09-14 21:31 in BASIC Stamp
Oh, and recently I changed the code on my display so that I could loop it. But to be safe I thought I would ask if I can do that or will it cause issues?

I used the code from DisplayDigits.bs2, but rather than use END, I used RETURN. Is that kosher?

Thanks,

Ron

(I'm scrambling to get my micro-controller and laptop up to snuff for a bunch of scouts - I'd like them to see the code. I'm also using the DisplayDigitsWithLookup.bs2, but not looped).

Comments

  • FranklinFranklin Posts: 4,747
    edited 2013-09-14 14:47
    It would help when you are asking code questions if you would include the code you are asking about (between [code] tags of course)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-14 14:58
    Or a link to the code in question.
  • ercoerco Posts: 20,257
    edited 2013-09-14 21:31
    From the WAM book, I presume?

    You can't use a RETURN, since there is no subroutine. The easiest way is to add a label near the start and end with a GOTO to loop back (or use a DO loop).

    Let's use a label with a GOTO.

    Find this line (a comment in green) near the start of the program:

    ' BAFG.CDE

    Right before that, add this new line:

    main:

    That's a label named "main". Not a command, just marks this location to come back to.

    Now go to the end of the program. Find the next to last line:

    DIRH=%00000000

    Right before that, add this new line:

    GOTO main

    And run the program. It should loop back to main: and do the numbers again. Note that this new GOTO added prevents the final two lines (DIRH and END) from ever being run. You can delete them.

    Assuming that works for you, try a DO loop. Change the main: label to a DO statement, which marks the beginning of a loop. Then change the GOTO main command to LOOP . It should work the same.
Sign In or Register to comment.