You are viewing an older revision! See the latest version

XBee Rock Paper Scissors

by Jonathan Young, Digi International

Would you like to be able to play automated Rock, Paper, Scissors electronically and wirelessly? Then this is the project for you! This project uses two Mbed microcontroller and a couple of Digi XBee radios to enable two people to choose a button representing either Rock, Paper, or Scissors and determines the winner on your own LCD screen.

Overview

Player 1 is ready to playPlayer 2 is ready to play
400500

Parts

  • Two solderless breadboards (MS MKKN2, AF 64, DK 438-1045-ND, SFE PRT-09567)
  • XBee radio (Series 2/ZB firmware) configured as a ZigBee Coordinator AT mode (Digi: XB24-27WIT-004, DK 602-1098-ND)
  • XBee radio (Series 2/ZB firmware) configured as a ZigBee Router AT mode (Digi: XB24-27WIT-004, DK 602-1098-ND)
  • One Arduino Uno board (MS MKSP4, SFE DEV-09950, AF 50)
  • Hookup wire or jumper wire kit (MS MKSEEED3, AF 153, DK 923351-ND, SFE PRT-00124)
  • USB A-to-B cable for Arduino (AF 62, DK 88732-9002, SFE CAB-00512)
  • XBee USB serial adapter (XBee Explorer or Digi Evaluation board) (AF 247, SFE WRL-08687)
  • Two XBee shields (Seeed Studio SLD01103P, Arduino A000065, SF WRL-10854)
  • Wire strippers (AF 147, DK PAL70057-ND, SFE TOL-08696)
  • One 16x2 character LCD display (with HD44780 parallel interface) (AF 181, DK 67-1758-ND, SFE LCD-00255)
  • One 10K ohm potentiometer (panel mount) (DK P3C3103-ND, RS 271-1715, SFE COM-09288)
  • Three 200 ohm resistor (DK P200BACT-ND)
  • 16-pin single-row male header (DK S1012E-36-ND, SFE PRT-00116)
  • Three momentary pushbutton switches (SPE COM-09190)
  • One Mbed Freedom board (Freescale FRDM-KL25Z)
  • Soldering tools (any hardware store)
  • An enthusiastic mind

Using the Arduino IDE

This project uses the Arduino software, known as the IDE, in order to program the Arduino Uno microcontroller. You can download it for free from the Arduino website software section at http://www.arduino.cc/en/Main/Software. There are many versions, so be sure to download the correct one. A basic guide to how to use it can be found at http://arduino.cc/en/Guide/HomePage

Using the Mbed Compiler

This project used the Mbed software, known as the online compiler, in order to program the Mbed microcontroller. You can sign up for a free account to access the online compiler at www.mbed.org. There are many versions of the Mbed, so make sure you select the correct platform. A basic guide to how to use it can be found at the same Mbed website.

Prepare and Configure your Coordinator Radio

  • Use X-CTU to set the designated coordinator radio in AT mode.
  • Configure the coordinator radio with a PAN ID (between 0x0 and 0xFFFFFFFFFFFFFFFF). Make sure you note this ID so that you can set up your router radio with the same one.
  • Enter in the High and Low destination addresses of your router radio.

Prepare and Configure your Router Radio

  • Use X-CTU to set the designated router radio in AT mode.
  • Configure the router radio with the PAN ID you set the coordinator radio with.
  • Set JV to 1 to ensure that your router attempts to rejoin the coordinator on startup.
  • Enter in the High and Low destination addresses of your coordinator radio.

Construct the Scoreboard Buttons

/media/uploads/JonathanYoung22193/fritz1.jpg Figure 1

/media/uploads/JonathanYoung22193/real1.jpg Figure 2

  • Insert your Coordinator XBee Radio onto the XBee shield, and then insert the shield onto the Mbed board.
  • Connect Mbed ground to the breadboard ground rail.
  • Connect Mbed 3.3 volt power to the breadboard power rail.
  • Connect breadboard power and ground rails on both sides of the breadboard.
  • Insert a pushbutton onto the breadboard towards the left end and centered. Ensure that the pushbutton connections are on different rails. If you are unsure, you can test this using an LED.
  • Connect the breadboard power to one end of the push button.
  • On the other end on the opposite side of the pushbutton, connect a wire to Mbed PTD5 (shield digital pin 9). On that same breadboard rail, connect a 200 ohm resistor to ground. As an optional enhancement, you can connect the ground pin of an LED to the breadboard ground rail and the power pin of the LED to the same connection on the pushbutton in order to be notified every time the button is pushed.
  • Repeat previous 3 steps for the other two pushbuttons, spacing them evenly towards the right. The middle will connect to Mbed PTD0 (shield digital pin 10) and the right pin will connect to Mbed PTD2 (shield pin 11).
  • Refer to figures 1 and 2 for visual reference.

Program the Mbed Microcontroller

Upload the following program to main.cpp of the Mbed microcontroller:

// Scoreboard

#include "mbed.h"
Serial xbee(USBTX, USBRX);
DigitalIn enable1(PTD5);
DigitalIn enable2(PTD0);
DigitalIn enable3(PTD2);

int main() {
    while(1) {
        if (enable1){
            xbee.printf("H");
            wait(.25);
            }
        if (enable2){
            xbee.printf("A");
            wait(.25);
            }
        if (enable3) {
            xbee.printf("R");
            wait(.25);
            }
        }
    }

All wikipages