XBee.println(F("============================"));
XBee.println();
}
Upload that, then switch over to your XCTU console window. You'll use the XBee connected to
your computer to control and read data from your Arduino.
All of the XBee magic occurs in serial prints and reads. To send data from the Arduino XBee,
XBee.print()
and
XBee.println()
's are used to write strings and other data. To read data from the
computer XBee, we can use
XBee.read()
, adding
XBee.available()
tests to check if data has come in.
That's all there is to it!
Check out the comments in the code for a line-by-line dissection.
Remote Controlling/Receiving
When the Arduino sketch first starts up, it will print a helpful usage menu. After that's printed, follow
the directions to send commands to your Arduino. To control pins 10, 11, 12, and 13, send the
equivalent characters (A, B, C, and D).
w#nnn
--
analog write
pin
#
to
nnn
. Use leading zeros for single- and double-digit values.
Example:
w6088
will write pin 6 to 88
d#v
--
digital write
pin
#
to
v
.
v
can be 1, h, or H for HIGH, and 0, l, or L for LOW.
Example:
ddh
will write pin 13 High
r#
-
digital read
digital pin
#
Example:
r3
will digtally read from pin 3.
a#
--
analog read
analog pin
#
Example:
a0
will read analog pin 0
In each case, the Arduino will respond with the action it's taken after you've sent a viable string.
As an initial test, try turning the D13 LED on and off, by sending
dd1
and
dd0
.
Page 21 of 24