In this activity, you create a multiplayer bomb defuser game.
If you get stuck, go to the Troubleshooting links at the end of the example.
2. Add the XBees to XCTU
Ensure that the XBee is seated firmly in the XBee USB adapter.
Plug the XBee USB adapter into your computer using the mini-USB cable provided.
Make sure you are in Configuration working mode.
Click Discover radio modules from the toolbar.
In the Discover radio devices dialog, select the serial port(s) in which you want to look for radio modules. If you do not know the serial ports where your modules are attached, select all ports. Click Next.
In the Set port parameters window, maintain the default values and click Finish.
As XCTU locates radio modules, they appear in the Discovering radio modules… dialog box. Once the discovery process has finished, click Add selected devices.
- At this point, you should see something like this in the Radio Modules section on the left:
The port number and MAC address do not necessarily have to be equal as shown in the picture.
3. Configure the XBees
Select two of the XBee modules to be the remote modules. The third and final module will be connected to the Arduino, and we refer to it as the local XBee.
- Restore the default settings of all XBees with the Load default firmware settings
Use XCTU to configure the following parameters:
Param 110px|Local XBee 110px|Remote XBee 1 110px|Remote XBee 2 Effect CH C C C Defines the frequency to use to communicate. This must be the same for all radios on your network. ID 2015 2015 2015 Defines the network that a radio will attach to. This must be the same for all radios on your network. DH — 0 0 DH and DL combined form the destination address. This is where the notifications are sent when the button value changes. The address being configured here is known as a short address. A short address is assigned during configuration. An XBee also has a long address (SH and SL combined) which is assigned permanently when the unit is manufactured. DL — 1234 1234 MY 1234 1235 1236 Defines the XBee's short address. AP API enabled w/PPP  — — Enables API mode with escaping. D0 — DI  DI  Sets the DIO0/AD0 pin as digital input in the remote XBees. This pin is connected to GND. D1 — DI  DI  Sets the DIO1/AD1 pin as digital input in the remote XBees. This pin is connected to GND. D2 — DI  DI  Sets the DIO2/AD2 pin as digital input in the remote XBees. This pin is connected to GND. D3 — DI  DI  Sets the DIO3/AD3 pin as digital input in the remote XBees. This pin is connected to GND. D7 — DO Low  DO Low  Sets the DIO7 pin as digital output low in the remote XBees. This pin is connected to an LED. IC — 0F 0F Configures the remote XBees to transmit an I/O sample when any pin changes.
00001111 (binary) = 0F (hexadecimal)
— keep the default value.
- Write the settings of all XBees with the Write radio settings button at the top of the Radio Configuration section.
4. Connect the components
Create the following circuit with each of the XBee breadboard adapters.
Ensure that you connect each wire to the same column on the breadboard as the indicated pin of the XBee breadboard adapter footprint. This ensures that the signals to the XBee are correct.
LEDs have a polarity and their orientation in the circuit matters. Ensure that you connect the cathode (short leg) of the LED to the same column on the breadboard as the resistor to ground.
Click to expand diagram
- Push down firmly on each breadboard adapter to ensure they are seated properly on the breadboards.
- Insert the remote XBees into the breadboard adapters. Push down firmly on each XBee to ensure they are seated properly on the adapter boards. Do not be afraid to use a little force.
Double check that the breadboard adapters and XBees are positioned in the correct location and oriented the same as the image below.
Incorrect placement can result in damage to components.
Click to expand diagram
5. Put it all together
- Place the local XBee on the XBee Shield connected to the Arduino.
- Apply power to the remote XBees using the 9V battery clips and batteries.
- Connect the Arduino to your computer using the micro USB cable.
- Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.
- Open the Arduino IDE.
- From the File menu select Open.
- Browse to the
bombgamefolder in the extracted zip archive, and select the
bombgame.inofile. Click Open.
Find the following section at the top of the file and modify it to include the MY values for your remote nodes.
Press Upload to upload the sketch to the Arduino and run it.
6. Play the game
- Disconnect one of the jumper wires (connected to DIO0-3) on player 1's board from ground.
- Disconnect a different jumper wire on player 2's board. If player 2 pulls the same wire, they lose (the bomb "explodes" and the LED lights up).
- Disconnect yet another wire on player 1's board and continue disconnecting wires, each player pulling one wire at a time, until the bomb "explodes."
- Once the bomb has exploded, do the following to restart the game:
- Reconnect all jumper wires on each of the bombs.
- Press the Reset button on the Arduino.
If you are encountering problems, these suggestions may help:
For more information about the hardware and software you use in this activity, see: