The little blue tank was built up from a Robot Shop tread base platform. Quite frankly I wasn’t impressed for how little came with the kit, considering it’s $70+ price tag. It came with the tank treads as little pieces of plastic and some loose steel dowels that had to be interconnected to make the chain forming the tread. Pretty tedious. But the kits was a single piece of metal as the base, a pair of rear idler wheels, a pair of front drive wheels, and the tank tread pieces. The DFRobot kits provide everything except the kitchen sink for their kits which are $30 to $40 cheaper than the Robot Shop offering. It is a pretty little thing though, and the royal blue powder coated finish is well done.
I put an Arduino into it for a brain, added a Hitec servo and sensor mount, a Sharp IR sensor, a targeting laser, and an Adafruit Motor Shield to make it go. The sensor mount holds the IR sensor and sits atop the servo. The servo sweeps the IR sensor giving distance measurements to the right, left and center. The laser is there for looks, it doesn’t really do anything except turn on when the tank is in forward gear.
I don’t take advantage of the PWM abilities with the setup. The tank is slow moving and the shock of motor reversal is pretty limited and compensated for in the motor shield.
I’m using a 7.2v LiPo battery to power the robot, it’s well within the operating range of all the components and has the added advantage of a charging pigtail. This means I don’t disassemble anything to charge the battery, I just plug it in. It takes about a half hour to charge the battery and gives about an hour of robot time before recharge is wise. The battery is stuck to the underside of the tank platform with double sided foam tape. It does a masterful job and can be removed if necessary.
The drive motors are basically the Solarbotics right angle drive motor and gearset. They were included with the tank kit, by the way. It makes for a slow but fairly powerful vehicle. It would climb right up a wall if it could stick. Negotiating across my bed with pillows and rumpled blankets proves no challenge at all for this little guy. Even when at a climb angle of about 60 degrees, it keeps on trucking. Beyond that it will fall over on its back, but it’s still remarkable to watch.
Its programming makes it shy away from obstacles detected to its right and left. If confronting an obstacle ahead, it backs up a couple of feet, pivots between 90 and 120 degrees (depending on the carpet) and then goes on ahead. The code I have included below is sans comments, but the programming is simple and pretty much self documenting. Anyone should be able to easily see what the code describes.
To make it easy on myself, I use an Adafruit Screw Shield in between the Arduino and motor controller. This gives easy access to all of the pins and made adding the servo and IR sensor a snap. I can add to the robot at will, using any available pins. It also provides a couple of extra places to tap Vcc and Ground, which is handy as well.
Here is a circuit diagram for the robots electronics.
And here is the Arduino sketch I use to drive the robot.
#include <Servo.h>
#include <AFMotor.h>
#define CENTER 90
#define LEFT 145
#define RIGHT 40AF_DCMotor motor1(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);Servo servo;
uint8_t i = 0;
unsigned long distance = 0;
float volts = 0;
const int irPin = 0;
const int laser = 13;
const int servoPin = 5;void setup() {
Serial.begin(9600);
Serial.println(“Start up”);
servo.attach(servoPin);
servo.write(CENTER);
motor1.setSpeed(255);
motor2.setSpeed(255);
motor1.run(RELEASE);
motor2.run(RELEASE);
}void loop() {
servo.write(CENTER);
delay(400);
scan();
if (distance < 35) {
backup();
delay(900);
right();
delay(1000);
}
servo.write(LEFT);
delay(400);
scan();
if (distance < 25) {
right();
delay(1000);
}
servo.write(RIGHT);
delay(400);
scan();
if (distance < 25) {
left();
delay(1000);
}
go();
}void go() {
digitalWrite(laser, HIGH);
Serial.println(“Forward”);
motor1.setSpeed(255);
motor2.setSpeed(255);
motor1.run(FORWARD);
motor2.run(FORWARD);
}void halt() {
Serial.println(“Halt”);
motor1.run(RELEASE);
motor2.run(RELEASE);
}void left() {
Serial.println(“Left”);
motor1.setSpeed(255);
motor2.setSpeed(180);
motor1.run(FORWARD);
motor2.run(BACKWARD);
}void right() {
Serial.println(“Right”);
motor1.setSpeed(180);
motor2.setSpeed(255);
motor1.run(BACKWARD);
motor2.run(FORWARD);
}void backup() {
digitalWrite(laser, LOW);
Serial.println(“Back Up”);
motor1.setSpeed(200);
motor2.setSpeed(200);
motor1.run(BACKWARD);
motor2.run(BACKWARD);
}unsigned long scan() {
Serial.print(“Scan: “);
volts = analogRead(irPin) * 0.0048828125;
distance = 65 * pow(volts, -1.10);
Serial.println(distance);
return(distance);
}
