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 hexadecimal 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. vcan 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 .
Then try setting analog values, or reading from pins. Maybe try making it
more advanced – have a button press trigger an XBee communication. Or
send an alert when an analog input rises past a certain threshold.
This example barely scrapes the surface of what the Arduino-XBee
combination is capable of. XBee’s allow you to remotely control your robot
from the comfy confines of your computer. Or you can set up a network of
XBees to monitor carbon-monoxide conditions in every room, while logging
to a single computer.
The power of XBees comes from their simplicity – they make your projects
wireless by simply “serial printing”.
Resources & Going Further
That should be enough to get you started. If you’re looking for more XBee
Page 1
of 1