User manual

www.sainsmart.com
Copyright © 2013 SainSmart All Rights Reserved
To upload a sketch to an SainSmart board with a XBee shield, you'll need to put both jumpers on
the shield to the "USB" setting (i.e. place them on the two pins closest to the edge of the board)
or remove them completely (but be sure not to lose them!). Then, you can upload a sketch
normally from the SainSmart environment. In this case, upload the Communication | Physical
Pixel sketch to one of the boards. This sketch instructs the board to turn on the LED attached to
pin 13 whenever it receives an 'H' over its serial connection, and turn the LED off when it gets an
'L'. You can test it by connecting to the board with the SainSmart serial monitor (be sure it's set at
9600 baud), typing an H, and pressing enter (or clicking send). The LED should turn on. Send an L
and the LED should turn off. If nothing happens, you may have an SainSmart board that doesn't
have a built-in LED on pin 13.
Once you've uploaded the Physical Pixel sketch and made sure that it's working, unplug the first
SainSmart board from the computer. Switch the jumpers to the XBee setting (i.e. place each on
the center pin and the pin farthest from the edge of the board). Now, you need to upload a
sketch to the other board. Make sure its jumpers are in the USB setting. Then upload the
following sketch to the board:
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
}
When it's finished uploading, you can check that it's working with the SainSmart serial monitor.
You should see H's and L's arriving one a second. Turn off the serial monitor and unplug the board.
Switch the jumpers to the XBee setting. Now connect both boards to the computer. After a few
seconds, you should see the LED on the first board turn on and off, once a second. (This is the
LED on the SainSmart board itself, not the one on the XBee shield, which conveys information
about the state of the XBee module.) If so, congratulations, your SainSmart boards are
communicating wirelessly. This may not seem that exciting when both boards are connected to
the same computer, but if you connect them to different computers (or power them with an
external power supply - being sure to switch the power jumper on the SainSmart board), they
should still be able to communicate.
Addressing
There are multiple parameters that need to be configured correctly for two modules to talk to
each other (although with the default settings, all modules should be able to talk to each other).
They need to be on the same network, as set by the ID parameter (see "Configuration" below for
more details on the parameters). The modules need to be on the same channel, as set by the CH
parameter. Finally, a module's destination address (DH and DL parameters) determine which