XBee Wireless SumoBot Tilt-Controller

Note that this tutorial is for the original BASIC Stamp SumoBot (retired). See the SumoBot WX Tutorial Series if your SumoBot has a blue FLiP module on it.

Connect a Memsic 2-axis accelerometer and XBee RF module to the BASIC Stamp HomeWork board and load some code, and you've got a wireless tilt controller.  Connect a second XBee RF module to a BASIC Stamp SumoBot board, and load some code into that, and you've got a tilt controlled SumoBot!  Since XBee modules can be configured to pair off in different networks, and even on different radio frequencies, you can have multiple pairs of wireless tilt controlled SumoBot robots in the same room without any radio interference or crosstalk.

SumoBot wrestling at the Parallax Robotics & Microcontroller Expo, using XBee + Memsic wireless robot controllers. Photo courtesy: ©2012 Rich Harman.

SumoBot wrestling at the 2012 Parallax Robotics and Microcontroller Expo

SumoBot robot and BASIC Stamp HomeWork Board with XBee RF modules

Want to make a tilt controlled Boe-Bot robot instead?  No problem, the SumoBot circuit works great on the Boe-Bot robot too.

Parts List

For each wireless tilt controller + robot, you will need:

  • (1) BASIC Stamp HomeWork Board (#555-28188) and a 9 V battery
  • (1) Memsic2125 Dual-Axis Accelerometer (#28017)
  • (2) XBee modules XB24-API 001 1mW with PCB antenna (#32404)
  • (2) XBee adapters:
    • XBee 5/3.3V adapters (#32401) require soldering, and are best for SumoBot applications 
           - OR -
    • XBee SIP adapters (#32402) need no soldering, and save breadboard space
  • (1) of these BASIC Stamp robots, fully assembled and tested
    • Boe-Bot Robot (#28132 or #28832)
           - OR - 
    • SumoBot Robot (#27400, or #27402 for a pair)
  • (1) Piezospeaker (included with the Boe-Bot and SumoBot kits)
  • (2) Stickers you can write on, and a pen
  • Misc. jumper wires

Tilt Controller and Robot Code Examples

Download Tilt Controlled SumoBots BS2 Code


  • Build, test, and get familiar with your BASIC Stamp controlled robot:
    • For a Boe-Bot, complete at least chapters 1-4 in Robotics with the Boe-Bot.
    • For a SumoBot, complete at least the SumoBot assembly manual chapters 1 and 2.

Build and Test the Circuits

  • Follow instructions in your XBee adapter documentation for assembling the adapter and socketing the XBee. 
  • Build Memsic2125 and XBee circuits on each HomeWork Board tilt controller.

Schematic and Wiring for Tilt Controller   BASIC Stamp HomeWork with XBee and Memsic MX2125 for RF Tilt Control (Schematic and Wiring)

  • As with the controller, follow instructions in your XBee adapter documentation for assembling the adapter and socketing the XBee. 
  • Build the XBee Receiver circuit on each SumoBot or Boe-Bot.

Schematic and Wiring for SumoBot
SumoBot Board with XBee for Remote Control
Note: The current photo shows SumoBot Vdd connected to XBee adapter VDD.  It needs to be updated to show SumoBot Vin connected to XBee adapter VDD.  Although the Vin = 6 V supply exceeds the XBee adapter's stated input range by 1 V, its voltage regulator can handle it.  The benefit is that it adds some headroom to prevent supply voltage fluctuations (like when the motors stall during a SumoBot competition) from causing a brownout condition for the XBee. 

Testing the Accelerometer

Let's make sure your accelerometer is wired correctly first.

  • User your BASIC Stamp Editor software to load Test Accelerometer.bs2 into one of your HomeWork boards.
  • Watch the Debug Terminal as you tilt your board in various directions.  Hold it level and both x and y values should be in the 2500 range.  Tilt it left/right, and the y axis values should vary.  The more you tilt, the further your measurements will vary from 2500.  In one direction down to about 1875, and up to about 3125 in the other direction.  The x axis should vary the same way as you tilt it either toward or away from you.  If it doesn't, check your wiring and try again.

Program the Tilt Controller

  • If you have more than one tilt controller, use a sticker to label your first one "B".
  • Connect your HomeWork Board to your computer via the programming cable.
  • Open XBee Tilt Controller CH B.bs2 and use your BASIC Stamp Editor software to load it into the HomeWork Board.
  • If you have a second tilt controller, label it "D", and load XBee Tilt Controller CH D.bs2 into it. 
  • If you have more tilt controllers, make a copy of XBee Tilt Controller CH D.bs2, and update the CH CON $0D to a new channel value and mark your tilt controller board with that value.  Your other options are: $0E, $0F, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, and $1A.  If you need one more option, use $0C.  It's the XBee modules default so save it for last to reduce the likelihood of other XBee network traffic. 

Example: Your third controller board could be labeled "E", and the program would be updated with CH CON $0E. 

Program the Receiver Robot(s)

  • If you have more than one SumoBot or Boe-Bot robot, use a sticker to label your first one "B".
  • Connect your robot's board to your computer via the programming cable.
  • Set your robot board's power switch to 1.
  • Make sure Tilt Controller B's battery is connected.
  • Open XBee Tilt Controlled SumoBot CH B.bs2 and use your BASIC Stamp Editor software to load it into your robot's board.
  • Keep an eye on the Debug Terminal and listen for the beeps. 
    (It beeps twice periodically as it configures the XBee, and then once repeatedly as it waits for communication to start.  When communication starts, the robot makes a 2 second long beep and then goes quiet, which means it's ready to be tilt controlled.  Skip to the Drive Your Robot instructions to get started with that.)
  • If you have a second robot, label it "D", and load XBee Tilt Controlled SumoBot CH D.bs2 into it. 
  • If you have more robots, follow the same procedure you used for multiple controllers.  Make sure to start with a copy of XBee Tilt Controlled SumoBot CH D.bs2, and update its CH CON directive just like you did with the tilt controllers.

Drive Your Robot!

  • Put your robot down on the floor, and move its switch to position 2 to power the servos.
  • Hold your tilt controller board flat in front of you, facing so that so that the 9 V battery is on the left.
  • Tilt the board forward and backward, so the robot rolls forward then backward.
  • Try making the robot turn while driving, by tilting the board forward-right, backward-left, and so forth.

If you made two tilt-controlled SumoBot robots, it's battle time.  Have fun!

If your robot starts beeping in the middle of tilt control, it might mean either your tilt controller's or robot's batteries are running low.

How it Works

If you tilt the HomeWork Board forward a little bit, the robot will roll forward slowly.  If you tilt it forward a lot, it will roll forward quickly. Tilting and rolling backward works the same way.  If you tilt the board to the right or left also, the robot will turn in that direction. 

The Memsic 2-axis accelerometer on your HomeWork Board can sense if the board is being held flat, or if it is tilted, how far and in what direction.    It reports these tilts on each axis (front-to-back and side-to-side) as pulses that last certain amounts of time.  The PBASIC program running in the BASIC Stamp HomeWork Board's onboard BASIC Stamp microcontroller makes it measure these pulses and convert them to numbers.  The program also makes the BASIC Stamp send these numbers as serial messages to the XBee transceiver, which in turn broadcasts these serial messages for the XBee on the robot.

The XBee on the robot receives the serial messages and forwards them to the robot's BASIC Stamp.  Its program converts the serial messages back to the numbers they represent.  Then, it does some math on the values to figure out the speed and direction it should make the servo turn.  It then sends a series of pulses to the servos.  The amount of time each pulse stays high is what tells the servo what speed and direction to turn.   

Learn much more about how it all works: 
To learn more about programming your robot for autonomous navigation, try Robotics with the Boe-Bot or the SumoBot Manual along with Applied Robotics with the SumoBot. 
To learn how the Memsic Dual-Axis Accelerometer works, try at least the Accelerometer - Getting Started tutorial
To learn how the Tilt Radio Control application works, see the Stamps in Class Mini Projects Project 9
To learn how the BASIC Stamp microcontrollers can communicate with each other using XBee radios,  try the Getting Started with XBee RF Modules textbook.

PDF versions of many manuals and textbooks can be obtained from the downloads section of the Parallax website.