Shop OBEX P1 Docs P2 Docs Learn Events
counter help — Parallax Forums

counter help

ArchiverArchiver Posts: 46,084
edited 2001-03-30 01:45 in General Discussion
Another way to skin the cat:

y var word
x var byte

' 0 to 999,999 as xxy,yyy
loop:
x = y + 1 / 10000 + x // 100
y = y + 1 // 10000
GOTO loop

Haven't tried it, but it ought to be pretty close to right. First
instruction should increment x if y would roll over to next 10,000,
then automatically roll x over to 0 as needed. Second statement
adds 1 to y and rolls y over to 0 if appropriate.

See the WRITE statement in the manual to see how to store in
eeprom--pretty straightforward.

Steve


On 30 Mar 01 at 0:29, aconti@n... wrote:

> can somone help me make a counter for the BS2 that can do 0 to
> 999,999 then restart at 0 to start all over again also how could i
> write the counter to the eeprom?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-03-30 01:29
    can somone help me make a counter for the BS2 that can do 0 to
    999,999 then restart at 0 to start all over again also how could i
    write the counter to the eeprom?

    thanks
    tony
  • ArchiverArchiver Posts: 46,084
    edited 2001-03-30 01:45
    [font=arial,helvetica]In a message dated 3/29/01 6:30:43 PM Central Standard Time,
    aconti@neo.rr.com writes:


    can somone help me make a counter for the BS2 that can do 0 to
    999,999 then restart at 0 to start all over again also how could i
    write the counter to the eeprom?



    The Stamp can't hold numbers that big in a single variable. ·You could do
    something like this though:

    thous VAR Word
    huns VAR Word

    Top:
    ·DEBUG Home,DEC thous,DEC3 huns
    ·huns = huns + 1
    ·IF (huns < 999) THEN Top
    ·huns = 0
    ·thous = thous + 1
    ·IF (thous < 999) THEN Top
    ·thous = 0
    ·GOTO Top



    [/font]
Sign In or Register to comment.