Skip to end of metadata
Go to start of metadata

In this activity, you create a game that requires you to follow directions until you can no longer keep up.

If you get stuck, go to the Troubleshooting links at the end of the example.

1. Requirements

Hardware

Two XBee 802.15.4 modules
 

One XBee breadboard adapter

One XBee USB adapter


One solderless breadboard

Six push-buttons


Yellow, Red, Blue, Green, Black, and White

Jumber wires
 
 

One 9V battery clip



 

One 9V battery


 

One breadboard power supply

One mini USB cable

Steps

Software

If you have not already done so, use the links below to download and install the software:

For further information about XCTU, go to the XCTU walkthrough.

2. Add the XBees to XCTU

  1. Ensure that the XBee is seated firmly in the XBee USB adapter.

  2. Plug the XBee USB adapter into your computer using the mini-USB cable provided.

  3. Open XCTU.

  4. Make sure you are in Configuration working mode.

  5. Click Discover radio modules from the toolbar.

  6. 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

  7. In the Set port parameters window, maintain the default values and click Finish.

  8. As XCTU locates radio modules, they appear in the Discovering radio modules… dialog box. Once the discovery process has finished, click Add selected devices.

  9. 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

  1. Restore the default settings of all XBees with the Load default firmware settings button at the top of the Radio Configuration section.

  2. Use XCTU to configure the following parameters:

    ParamProcessing XBeeButton board XBeeEffect
    CHCCDefines the frequency to use to communicate. This must be the same for all radios on your network.
    ID20152015Defines the network that a radio will attach to. This must be the same for all radios on your network.
    DH0DH and DL combined form the destination address. This is where the notifications are sent when any 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.
    DL1234
    MY1234Defines the XBee's short address.
    APAPI enabled [1]Enables API mode.
    D0DI [3]Sets the DIO0/AD0 pin as digital input in the board XBee. This pin is connected to a button.
    D1DI [3]Sets the DIO1/AD1 pin as digital input in the board XBee. This pin is connected to a button.
    D2DI [3]Sets the DIO2/AD2 pin as digital input in the board XBee. This pin is connected to a button.
    D3DI [3]Sets the DIO3/AD3 pin as digital input in the board XBee. This pin is connected to a button.
    D4DI [3]Sets the DIO4/AD4 pin as digital input in the board XBee. This pin is connected to a button.
    D6DI [3]Sets the DIO6/AD6 pin as digital input in the board XBee. This pin is connected to a button.
    IC5FConfigures the button board XBee to transmit an IO sample when any button (DIO0/AD0, DIO1/AD1, DIO2/AD2, DIO3/AD3, DIO4/AD4, or DIO6/AD6) changes.
    01011111 (binary) = 5F (hexadecimal)

    — keep the default value.

  3. Write the settings of all XBees with the Write radio settings  button at the top of the Radio Configuration section.

4. Connect the components

  1. Create the following circuit with the breadboard and the XBee breadboard adapter.

    Ensure that each wire is connected to the same column on the breadboard as the pin of the XBee breadboard adapter footprint. This will ensure that the signals to the XBee are correct.

    Click to expand diagram

    The Processing application is written with button colors in the order: Yellow, Red, Blue, Green, Black, White. If you change the order, remember to change the colors in the application as well.

  2. Push down firmly on the breadboard adapter board to ensure it is seated properly on the breadboard. Do not be afraid to use a little force.

  3. Insert the button board XBee into the breadboard adapter. Push down firmly on the XBee to ensure it is seated properly on the breadboard adapter.

  4. Double check that the breadboard adapter and XBee are positioned in the correct location and oriented the same as the image below. Incorrect placement has the potential to result in damage to components.

    Click to expand diagram

5. Put it all together

  1. Plug the XBee USB adapter into the computer where you will run the Processing application.

  2. Apply power using the 9V battery and battery clip.

  3. Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.

  4. Open the Processing application.

  5. From the File menu select Open.

  6. Browse to the follow_the_leader folder from the extracted archive, and select the follow_the_leader.pde file. Click Open.

  7. Find the following section at the top of the file and add the XBee serial port where your XBee is attached to.

     How do I find the serial port of my module?

    You can remove the XBee Grove Development Board from the USB port and see which port name disappears from your port list. The name that disappears is your XBee board.

    Many people figure out which port is right via trial and error, but you can also use XCTU to find it:

    1. Open XCTU and discover the radio modules attached to your computer by clicking  on the top-left corner.
    2. Select all ports to be scanned.
    3. Click Next and then Finish.
    4. Once the discovery process has finished, a new window notifies you how many devices have been found and their details. The serial port and the baud rate are shown in the Port label.

    If you are using different colors, or they are in a different order, this is also where you should change the description. Add any other adjectives that may apply to your environment following the pattern you see here.

  8. Press Play to run the sketch.

6. Play the game

  1. Follow the directions on the screen as fast as you can.

  2. Continue until the game is too fast to get the right button in time.

7. Exercises for the reader

If you're ready to move beyond this exercise and extend the example, try the following:

  • Add scoring to the Processing application. Compete with friends to see who can get the most correct before failing.

8. Troubleshooting

If you are encountering problems, these suggestions may help:

General
 How do I find the serial port of my module?

You can remove the XBee Grove Development Board from the USB port and see which port name disappears from your port list. The name that disappears is your XBee board.

Many people figure out which port is right via trial and error, but you can also use XCTU to find it:

  1. Open XCTU and discover the radio modules attached to your computer by clicking  on the top-left corner.
  2. Select all ports to be scanned.
  3. Click Next and then Finish.
  4. Once the discovery process has finished, a new window notifies you how many devices have been found and their details. The serial port and the baud rate are shown in the Port label.
 An error saying that the port is already in use by other applications is displayed.

The serial port where the local XBee module is connected can only be in use by one application. Check that the connection with the module in the XCTU console is closed and there are no other applications using the port.

 The error 'Device driver software was not successfully installed' is displayed.

Sometimes when you connect the XBee Grove Development Board into you computer, the operating system cannot install the driver automatically. If you get that error, try to remove and re-insert the board into your computer. If the OS is still unable to install the driver, remove and re-insert the board into another USB port.

As a last resort, install manually the USB drivers following the instructions that appear in the step 4 of the Downloading and installing XCTU section.

 How can I physically identify the XBee modules?

Once you have added the modules to XCTU, a simple way to identify them is to read the radio settings of each one and check the Rx and Tx LEDs of the XBee Grove Development Boards. These LEDs indicate that the XBee module is receiving (Rx) or transmitting (Tx) information through the serial port.

When you read or write the settings of a module, its Rx and Tx LEDs blink, so you can identify which module is connected to each serial port.

XCTU
 An error is reported when installing XCTU.

XCTU requires Administrator permissions

Check that you have Administrator access on the machine where you are installing XCTU. On Windows systems, a User Account Control dialog may appear when you install XCTU or try to run the XCTU program. You must answer yes when prompted to allow the program to make changes to your computer, or XCTU will not work correctly. Note that you may also need to talk to your network manager to gain permission to install or run applications as administrator.

 No radios are found when discovery is performed or no serial ports are listed.

Check cables

Double check all cables. The USB cable should be firmly and fully attached to both the computer and the XBee Grove Development Board. When attached correctly, the association LED on the adapter will be lit.

Check that the XBee is fully seated in the XBee Grove Development Board

When the XBee is correctly installed, it should be pushed fully into the board and no air or metal should be visible between the plastic of the adapter socket and the XBee headers. Also, double check that all ten pins on each side of the XBee made it into a matching hole in the socket.

Check the XBee orientation

The angled "nose" of the XBee should match the lines on the silk screening of the board and point away from the USB socket on the XBee Grove Development Board.

Check driver installation

Drivers are installed the first time the XBee Grove Development Board is plugged in. If this process is not complete or has failed, try the following steps:

  1. Remove and re-insert the board into your computer. This may cause driver installation to re-occur.
  2. Remove and re-insert the board into another USB port.
  3. (Windows) Open Computer management, find the failing device in the Device Manager section and remove it.
  4. You can download drivers for all major operating systems from FTDI for manual installation.

Check if the modules are sleeping

The On/Sleep LED of the XBee Grove Development Board indicates if the module is awake (LED on) or asleep (LED off). When a module is sleeping, it cannot be discovered in XCTU, so press the Commissioning button and will wake up for 30 seconds.

 After resetting an XBee to factory defaults, XCTU reports errors for the KY and DD settings.

This is a known issue with the 6.1.2 versions of XCTU or less.

When the Invalid settings dialog appears, it is safe to continue to write settings.

  • AES Encryption Key (KY) is a setting that must be set by the user when encryption is used and does not apply with factory settings.
  • Device Type Identifier (DD) is a diagnostic parameter which is not used in the operation of the radio and can safely be set to any value.
Circuit assembly
 Do I need to match the wire colors used in the diagrams?

No, in many of the diagrams the color of the wires indicates something unique about its role in the circuit such as power, ground, and so forth. However, the color does not matter when assembling the circuit.

My circuit doesn't work
 Things to check first.

Is everything fully inserted?

Make sure that all components are fully inserted into the breadboard, sockets or connectors. When connecting, ensure that the wire or headers are aligned correctly and push firmly and evenly on the part. Header pins on the XBee or breadboard carrier boards should insert fully such that the plastic molding sits flush with the socket or board.

Do wires connect to the correct pins?

Check the diagram against the circuit that you have built. It can be easy to place wires so that they are one row off from the desired location. If you have any questions about which portions of the breadboard are connected, check out How to use a breadboard which describes the anatomy of a breadboard. This will help you to understand component placement in each game.

Are all XBees configured correctly?

Make sure that the configuration of each XBee matches the settings provided in the instructions. Before you configure the XBee, restore each module's default settings using the factory defaults button at the top of the Radio Configuration section.

 An LED does not light when expected.

Check LED polarity

An LED has a correct installation direction. When installed backwards it will not light when expected. The long leg of the LED (anode) must be provided with a higher voltage than the short leg (cathode). In most of the projects, the cathode is connected to ground and the voltage to the anode is controlled by connecting it to a digital output on the XBee or Arduino.

Another way to identify the cathode if you've clipped the wires, or want to check while it is installed is to look at the colored plastic housing. Many LEDs will make the body flat on the cathode side as well.

Check resistor

Resistors are placed in series with each LED to ensure that it does not receive too much current. Compare the stripes on the resistor being used to check that you are using the correct resistor. The resistors in these games are 330Ω and should have stripes that are orange-orange-brown.

Arduino
 Do you get an error when uploading code to the Arduino?

If the Arduino IDE displays the message "Problem uploading to board." after you click Upload, enable the option "Show verbose output during upload" in the preferences (File menu > Preferences):

Click Upload again, and find the error message that appears above the line Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Does the error message read "avr_dude: ser_send(): write error: sorry no info avail"?

This error appears occasionally on 64-bit versions of Windows. In order to upload code successfully to the Arduino, you must reset the Arduino at a specific time during the upload.

  1. In the Arduino IDE, click Upload.
  2. Press and hold the RESET button on the Arduino board.
  3. Release the RESET button on the Arduino board when messages like the following appear in the Arduino message window:

  4. After the code is uploaded to the Arduino, the following message appears at the bottom of the window:

Learn more

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

  • No labels