Setting Up the
Telebot Remote
52 SERVO 11.2012
Telebot uses two Arduino
controllers. A main Arduino on the
Telebot provides the primary functions
of the robot such as motor control,
and a remote control sends wireless
commands to the Telebot. The remote
uses any of several sensors to provide
actuation; I’ll be demonstrating the
use of a five-position switch to control
forward/back and right/left motion.
A separate Arduino is used to process
these sensors. Both the Telebot and
the remote control are outfitted with
XBee radios for transmitting the
commands from the remote.
The remote for the Telebot consists
of an Arduino Uno development board,
prototyping shield with mini solderless
breadboard, battery, Series 1 XBee
radio, and a Parallax five-position
switch. The five-position switch is
literally five switches in one, arranged
to provide up/down/left/right
navigation. (The fifth switch is a center
pushbutton.) Each of the five switches
has its own pull-up resistor, and is
interfaced to the Arduino with only a
simple wire connection.
Figure 3 shows a drilling and
cutting layout for the handheld remote.
The Arduino is powered by a nine volt
battery which you can hold in place
with a battery clip or piece of double-sided foam tape. Figure 4 shows the
five-position switch.
Alternatives to using a multi-axis
switch include an accelerometer and
tilt compensated compass.
Begin construction of the Telebot
remote by cutting and drilling the base
plate in Figure 3. Mount the Arduino
to the plate using a set of four 1/2”
long nylon standoffs and 4-40 machine
screws. Use 4-40 x 1/2” flat head
screws on the underside of the plate,
and 4-40 x 3/8” screws to mount the
Arduino board to the standoffs. If
using metal screws, add a plastic
washer to prevent any possible shorts.
Attach a standard protoshield over
the Arduino. If the shield does not
already have a mini breadboard on it,
attach one using double-sided foam
tape (most breadboards have the tape
already applied).
FIGURE 3.
Layout guide
for the remote
baseplate. Use
the Arduino
and (optional)
Devantech
CMPS10
compass for
marking holes
for drilling.
Listing 1 — Telebot_Transmit.ino.
#include <SoftwareSerial.h>
// Pin connections for switch (includes power and ground)
const int pwrPin = 7;
const int gndPin = 4;
const int upBttn = 5;
const int crBttn = 6;
const int rtBttn = 8;
const int dnBttn = 9;
const int ltBttn = 10;
// Pin connections for XBee radio
const int xb_rx = 2;
const int xb_tx = 3;
SoftwareSerial Xbee(xb_rx, xb_tx);
int keyDelay = 300; // Limit keypress to one per 300ms
long previousMillis = 0; // Stores last time switch updated
void setup() {
Xbee.begin(9600);
// Set power to 5-position switch
pinMode(pwrPin, OUTPUT);
digitalWrite(pwrPin, HIGH);
pinMode(gndPin, OUTPUT);
digitalWrite(gndPin, LOW);
}
void loop() {
unsigned long currentMillis = millis();
// Prevents bounce
if(currentMillis - previousMillis > keyDelay) {
previousMillis = currentMillis;
if(digitalRead(ltBttn) == LOW)
Xbee.print("l");
if(digitalRead(rtBttn)== LOW)
Xbee.print("r");
if(digitalRead(upBttn) == LOW)
Xbee.print("u");
if(digitalRead(dnBttn) == LOW)
Xbee.print("d");
if(digitalRead(crBttn) == LOW)
Xbee.print("c");
}
}