PDA

View Full Version : xbee and prop chapter 4 tutorial



fsb
11-21-2010, 10:35 PM
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

Roger Lee
11-21-2010, 10:51 PM
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.

fsb
11-22-2010, 02:02 AM
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 Lee
11-22-2010, 02:23 AM
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

repeat ' <--- insert this line
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)

fsb
11-22-2010, 04:59 AM
Thanks!!!

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

That helped alot

fsb