Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this activity, you create a multiplayer bomb defuser game.

Multiexcerpt include
nopaneltrue
MultiExcerptNameonlyTroubleshootingInfo
DisableCachingtrue
PageWithExcerptRFKitsCommon:More excerpts

Numbered Headings
skip-headingsh3, h4
start-numbering-ath2
Section
Column

Requirements

Panel
borderColor#efefef
bgColorwhite
titleBGColor#efefef
borderWidth0
titleHardware

Three XBee 802.15.4 modules
 

One Arduino Leonardo


One XBee Shield


Two XBee breadboard adapters

One XBee USB adapter


to configure the XBees

Two solderness breadboards
 

Two LEDs

Two 330Ω resistors



Jumper wires

Two 9V battery clips


Two 9V batteries

 

Two breadboard power supplies

One micro USB cable


One min USB cable

Column
width325px
Panel
borderColorwhite
bgColor#efefef
titleColorwhite
titleBGColor#4f5454
borderWidth2
borderStylesolid
titleSteps

Table of Contents
maxLevel2
minLevel2
stylenone
classtoc

Panel
borderColor#efefef
bgColorwhite
titleBGColor#efefef
borderWidth0
titleSoftware

Multiexcerpt include
nopaneltrue
MultiExcerptNamearduinoSoftwareRequirements
DisableCachingtrue
PageWithExcerptMore excerpts

Multiexcerpt include
nopaneltrue
MultiExcerptNameXCTUWalktroughTip
DisableCachingtrue
PageWithExcerptRFKitsCommon:More excerpts

Add the XBees to XCTU

Include Page
Add the XBees to XCTU
Add the XBees to XCTU

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.

  1. Multiexcerpt include
    nopaneltrue
    MultiExcerptNamerestoreDefaultsInfo
    DisableCachingtrue
    PageWithExcerptRFKitsCommon:More excerpts


  2. Use XCTU to configure the following parameters:

    Param110px|Local XBee110px|Remote XBee 1110px|Remote XBee 2Effect
    CHCCCDefines the frequency to use to communicate. This must be the same for all radios on your network.
    ID201520152015Defines the network that a radio will attach to. This must be the same for all radios on your network.
    DH00DH 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.
    DL12341234
    MY123412351236Defines the XBee's short address.
    APAPI enabled w/PPP [2]Enables API mode with escaping.
    D0DI [3]DI [3]Sets the DIO0/AD0 pin as digital input in the remote XBees. This pin is connected to GND.
    D1DI [3]DI [3]Sets the DIO1/AD1 pin as digital input in the remote XBees. This pin is connected to GND.
    D2DI [3]DI [3]Sets the DIO2/AD2 pin as digital input in the remote XBees. This pin is connected to GND.
    D3DI [3]DI [3]Sets the DIO3/AD3 pin as digital input in the remote XBees. This pin is connected to GND.
    D7DO Low [4]DO Low [4]Sets the DIO7 pin as digital output low in the remote XBees. This pin is connected to an LED.
    IC0F0FConfigures the remote XBees to transmit an I/O sample when any pin changes.
    00001111 (binary) = 0F (hexadecimal) 

    — keep the default value.

  3. Multiexcerpt include
    nopaneltrue
    MultiExcerptNamewriteSettingsInfo
    DisableCachingtrue
    PageWithExcerptRFKitsCommon:More excerpts

Connect the components

  1. Create the following circuit with each of the XBee breadboard adapters.

    Note

    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.

    Note

    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

  2. Push down firmly on each breadboard adapter to ensure they are seated properly on the breadboards.
     
  3. 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.
     
  4. 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

Put it all together

  1. Place the local XBee on the XBee Shield connected to the Arduino.

  2. Apply power to the remote XBees using the 9V battery clips and batteries.

  3. Connect the Arduino to your computer using the micro USB cable.

  4. Download and extract the latest zip archive from the
    Digi external link macro
    nameXBee/Arduino Compatible Coding Platform release
    hrefhttps://github.com/digidotcom/XBeeArduinoCodingPlatform/releases
    page.

  5. Open the Arduino IDE.

  6. From the File menu select Open.

  7. Browse to the bombgame folder in the extracted zip archive, and select the bombgame.ino file. Click Open.

  8. Find the following section at the top of the file and modify it to include the MY values for your remote nodes.

    Code Block
    themeEclipse
    languagecpp
    // Change as necessary
    uint16_t REMOTE_ADDR[] = { 0x1235, 0x1236 }; // MY parameter values of remote nodes
  9. Press Upload to upload the sketch to the Arduino and run it.

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.

Troubleshooting

If you are encountering problems, these suggestions may help:

Include Page
Troubleshooting
Troubleshooting

Learn more

For more information about the hardware and software you use in this activity, see:

  • Digi external link macro
    nameUsing XCTU to configure an XBee
    href../XCTU/Configure+your+modules
  • Digi external link macro
    nameMore about 802.15.4 networks
    hrefhttp://en.wikipedia.org/wiki/IEEE_802.15.4
  • Digi external link macro
    nameMore about XBee digital I/O
    href../WirelessConnectivityKit/Ins+and+Outs
  • Digi external link macro
    nameMore about breadboards
    hrefhttps://learn.sparkfun.com/tutorials/how-to-use-a-breadboard
  • Digi external link macro
    nameConnecting power
    hrefhttps://learn.sparkfun.com/tutorials/how-to-power-a-project
  • Digi external link macro
    nameWiring a switch
    hrefhttps://learn.sparkfun.com/tutorials/switch-basics
  • Digi external link macro
    nameWiring an LED
    hrefhttps://learn.sparkfun.com/tutorials/light-emitting-diodes-leds