Joystick with XBee

Table of ContentsIMG_2692

  1. Introduction
  2. Assemble the Parts
  3. Configure the Radio
  4. Wire up the Circuit
  5. Use it!


1) Introduction

Let's get physical! Join this joystick to your XBee radio for a terrific way to add movement to your project, sending all kinds of things in different directions.

Achieve full wireless control of  household robots, industrial equipment, safety cameras...even stratosphere-seeking weather balloons. Set about inventing a new class of cat toys or create a new way to interact with museum exhibits. Maybe you'd like to make an interactive lawn sprinkler that waters your name in the grass? Here's a terrific way to control it! This tutorial walks you through the easy way to connect a joystick to your XBee. Create a wonderful wireless controller and drive your dreams!

2) Assemble the Parts


To hook up a joystick to an XBee, you'll need:

3) Configure the Radio

If you're not familiar with configuring radios using AT commands, review the steps in the Basic XBee 802.15.4 Chat tutorial, which walks you through configuring CoolTerm to program the radios.

  • Insert the XBee into the Explorer USB and connect it to your computer.
  • Launch CoolTerm and connect to the XBee.
  • Here are the commands we're going to use to configure the radio:
Function Command Parameter
Reset ATRE N/A (resets the radio to its factory settings)
PAN ID ATID 3001 (any address from 0 to FFFE will do)
MY Address ATMY 1
Destination address high ATDH 0 (indicates a 16-bit address)
Destination address low ATDL 2 (the address of the receiving radio)
Pin 0 I/O configuration ATD0 3 (digital input)
Pin 1 I/O configuration ATD1 3 (digital input)
Pin 2 I/O configuration ATD2 3 (digital input)
Pin 3 I/O configuration ATD3 3 (digital input)
Change detection ATIC F (bitmap field: first four inputs send samples on change, SEE BELOW for more information)
Write to memory ATWR N/A (save the settings to flash memory)
  • Here's what your terminal session might look like. The user input is in bold:
+++
OK
ATRE
OK
ATID 3001
OK
ATMY 1
OK
ATDH 0
OK
ATDL 2
OK
ATD0 3
OK
ATD1 3
OK
ATD2 3
OK
ATD3 3
OK
ATIC F
OK
ATWR
OK
ATID
3001
ATMY
1
ATDH
0
ATDL
2
ATD0
3
ATD1
3
ATD2
3
ATD3
3
ATIC
F
ATWR
OK

Note: Remember to issue the ATWR command when you're done so that the settings are saved in the radio's flash memory. If you don't issue this command, the radio will revert to its old settings when it loses power.

Note: the calculator in Macintosh can easily convert bits to hexadecimals. Above you can see that the first four bits are on, and the base-16 (hexadecimal) equivalent is displayed as 0xF.

4) Wire up the Circuit

  • Place the XBee adapter into the breadboard and wire up the power buses to each other. Next, connect the VCC terminal of the XBee adapter to the positive rail and the ground terminal to the negative rail.

  • The joystick is really a set of four switches that all share a common ground. To make it easier to connect them to a breadboard, you can solder male header pins onto each. We kept the common wire (typically the black one) separate so that it could be connected directly to the negative power rail.

  • Connect the common wire to the ground power rail. Connect the remaining joystick switch wires to XBee input pins D0, D1, D2 and D3 (physical pins 20, 19, 18 and 17 on the right-hand side of the XBee).

  • We made it easier to attach the battery holder to the breadboard by soldering some male headers onto its positive and negative wiring leads.

  • Connect the battery pack directly to the ground and power rails.

  • Insert your configured XBee into the breadboard adapter and your XBee Joystick is all done!

  • Below is a breadboard layout of the circuit along with a schematic.

Note: Your joystick output wiring arrangement might be different, so always check the operation to confirm before finalizing your project.

5) Use it!


Now that you know how to connect a joystick to an XBee radio, take a look at our output tutorials for ideas on where to send the signals. The video above shows the joystick connected to a group of four wireless LEDs. You might want to try controlling stepper motors to create directional movement, orchestrating water pumps into a casino-style fountain or harvesting crops from the comfort of your porch swing. Every which way is a joy!

Tags: 802.15.4