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.
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
- Restore the default settings of all XBees with the Load default firmware settings
Use XCTU to configure the following parameters:
Param Processing XBee Button board XBee Effect CH C C Defines the frequency to use to communicate. This must be the same for all radios on your network. ID 2015 2015 Defines the network that a radio will attach to. This must be the same for all radios on your network. DH — 0 DH 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. DL — 1234 MY 1234 — Defines the XBee's short address. AP API enabled  — Enables API mode. D0 — DI  Sets the DIO0/AD0 pin as digital input in the board XBee. This pin is connected to a button. D1 — DI  Sets the DIO1/AD1 pin as digital input in the board XBee. This pin is connected to a button. D2 — DI  Sets the DIO2/AD2 pin as digital input in the board XBee. This pin is connected to a button. D3 — DI  Sets the DIO3/AD3 pin as digital input in the board XBee. This pin is connected to a button. D4 — DI  Sets the DIO4/AD4 pin as digital input in the board XBee. This pin is connected to a button. D6 — DI  Sets the DIO6/AD6 pin as digital input in the board XBee. This pin is connected to a button. IC — 5F Configures 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.
- 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 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.
- 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.
- 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.
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
- Plug the XBee USB adapter into the computer where you will run the Processing application.
- Apply power using the 9V battery and battery clip.
- Download and extract the latest zip archive from the XBee/Arduino Compatible Coding Platform release page.
- Open the Processing application.
- From the File menu select Open.
- Browse to the
follow_the_leaderfolder from the extracted archive, and select the
follow_the_leader.pdefile. Click Open.
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:
- Open XCTU and discover the radio modules attached to your computer by clicking on the top-left corner.
- Select all ports to be scanned.
- Click Next and then Finish.
- 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.
- Press Play to run the sketch.
6. Play the game
Follow the directions on the screen as fast as you can.
- 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.
If you are encountering problems, these suggestions may help:
For more information about the hardware and software you use in this activity, see: