Shop OBEX P1 Docs P2 Docs Learn Events
Where is the bug ? — Parallax Forums

Where is the bug ?

GI JOEGI JOE Posts: 2
edited 2004-07-27 14:54 in BASIC Stamp
Try this simple program with a bicolor LED between pins 11 & 0 on a BS HW Board.
In the·"FOR" statement, if the TO 270 is changed to 260 or less the
program executes the correct number of times, a value of 270 or
greater causes the program to go into an endless loop. WHY?

roll.gif

' {$STAMP BS2}
' {$PBASIC 2.5}
' usig a bicolor led between pins 11&0
counter VAR Byte
FOR counter=0 TO 270 STEP 10
HIGH 11:LOW 0 'pin 11 hi pin 0 lo
PAUSE 50
LOW 11:HIGH 0 'pin 0 hi pin 11 lo
PAUSE 50
NEXT
END

Comments

  • DntGvaShtDntGvaSht Posts: 65
    edited 2004-07-25 21:31
    using BYTE as the variable type only allows 256 possible values.
    try using WORD as the variable type instead, allowing 65536 values.

    hope this helps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "01101000 01100101 01101100 01101100 01101111 00100000 01110111 0110111 01101111 01110010 01101100 01100100 00100001"
  • GI JOEGI JOE Posts: 2
    edited 2004-07-25 21:47
    That was the answer, good job, and thank you
  • JohnSchwabJohnSchwab Posts: 5
    edited 2004-07-27 14:54
    counter is defined as a byte which gives you 256 possibilities, and wraps around to zero before it hits the elusive 270.

    /John
Sign In or Register to comment.