Shop OBEX P1 Docs P2 Docs Learn Events
xbee and prop chapter 4 tutorial — Parallax Forums

xbee and prop chapter 4 tutorial

fsbfsb Posts: 24
edited 2010-11-21 20:59 in Propeller 1
I have a stupid newb question.

In the xbee tutorial by step lindsay in chapter 4, there is a program called "simple debug" for the prop in spin.

The program essentially transmits such that the receiving xbee counts up from one to 20.

It runs fine, but it doesn't loop.

Is it supposed to? I thought that was the purpose of the "repeat" statement.

If not, how would one write it so it repeats?

fsb

Comments

  • Roger LeeRoger Lee Posts: 339
    edited 2010-11-21 14:51
    When you say "it runs fine", does that mean it counts from 1 to 20?

    If so then the repeat loop is working as it should.
  • fsbfsb Posts: 24
    edited 2010-11-21 18:02
    Yes, it counts from 1 to 20. Then stops. What I was trying to do is have it repetitively count from one to 20, endlessly. (no reason, just a mental exercise to help me understand spin)

    fsb
  • Roger LeeRoger Lee Posts: 339
    edited 2010-11-21 18:23
    Sure, change this:
    Pub Start | Counter
    XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
    
    Delay (1000)                       ' one second delay
    repeat Counter from 1 to 20        ' count up to 20
    
      ' Send to Base
      XB.str(string("Count is:"))      ' send string
      XB.dec(Counter)                  ' send decimal value
      XB.Tx(CR)                        ' send Carriage Return
    
      Delay(250)
    

    To this:
    Pub Start | Counter
    XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
    
    Delay (1000)                       ' one second delay
    
    [COLOR=Red]repeat      '  <---   insert this line[/COLOR]
        repeat Counter from 1 to 20        ' count up to 20
    
          ' Send to Base
          XB.str(string("Count is:"))      ' send string
          XB.dec(Counter)                  ' send decimal value
          XB.Tx(CR)                        ' send Carriage Return
    
          Delay(250)
    
  • fsbfsb Posts: 24
    edited 2010-11-21 20:59
    Thanks!!!

    That did the trick. I see the importance of proper indentation.

    That helped alot

    fsb
Sign In or Register to comment.