In this tutorial, we will learn how to make an Arduino Tracked Robot. It is controlled by an Android mobile app. Android mobile app and Tracked Robot are connected through Bluetooth. The specialty of this is the ability to be controlled through the mobile app and to remember the steps and operate again and again. we can program the movements of this robot as we want. The specialty of this is that it uses a tracked chassis kit. So it can be easily controlled on any surface.
You can watch the following videos or read the written tutorial below.
This video is in two parts. The first video explains how to remove the two gear motors that come with the YP100 Metal Tracked Robot Tank Chassis and connect the two nema17 stepper motors. The second video explains how to make a Programmable Tracked Robot.
Overview
This robot, made of YP100 Metal Tracked Robot Tank Chassis, can be controlled by Bluetooth up to a distance of 15 meters. Instead of wheels, it has a track like a war tank, so it can travel in any terrain. The Android app was made with MIT APP Inverter. It can be controlled as well as programmed using the mobile app. For programming the automatic robot movement with this app, when we press the “SAVE” button we simply store the current positions of the stepper motors into arrays. Then when we press the “RUN” button, we call the runSteps() custom function which executes or runs through all stored steps using some for and while loops.
Components Needed
Before we begin, make sure you have gathered all the necessary components. The purchase links are in the description of my YouTube video.
- YP100 Metal Tracked Robot Tank Chassis
- Arduino Uno
- CNC Shield V3
- Two A4988 Stepper Motor Drivers
- 2pin mini jumper connecter
- Two NEMA 17 stepper motors
- HC-05 or HC-06 Bluetooth module
- 3S LiPo battery and XT60 Connecter
- Step-down buck converter
- Jumper wires
- DC Extension Connectors Male jack
- Soldering iron and solder
- Screwdriver and assorted screws
- Glue Gun
- Mobile device with the Arduino Smart Tank Robot app installed
Assemble the Robot Chassis
The first video shows how to assemble the YP100 Metal Tracked Robot Tank Chassis kit. Do not install the two motors that come with it while assembling. For that, install the two NEMA 17 stepper motors as shown in the second video.
A 3d print part is needed for the shaft of the stepper motor to install it. Get the STL file from the link below.
The CNC Shield V3 is mounted on an Arduino board. Attach the Arduino Uno Case to the chassis using a glue gun. Install the mini jumpers as shown in the figure. You can change the speed of the stepper motor by changing the way the mini jumper is installed. Eighth step (microstep resolution) as I install. When installing A4988 stepper driver, CNC Shield v3, do not connect the EN pin of A4988 stepper driver to CNC Shield. Bend or cut off the EN pin of the A4988 stepper drivers so that it does not connect to the CNC shield. Mount the CNC Shield V3 onto the Arduino Uno, ensuring proper alignment with the pins.
Install the mini jumpers as shown in the figure. You can change the speed of the stepper motor by changing the way the mini jumper is installed.
Eighth step (microstep resolution) as I install.
When installing A4988 stepper driver, CNC Shield v3, do not connect the EN pin of A4988 stepper driver to CNC Shield.
Bend or cut off the EN pin of the A4988 stepper drivers so that it does not connect to the CNC shield.
Mount the CNC Shield V3 onto the Arduino Uno, ensuring proper alignment with the pins.
Power the CNC Shield and Arduino UNO
Power the CNC Shield and Arduino UNO Provide power to the CNC shield by connecting the positive (12V ) and negative (GND) terminals of the XT60 connecter to the “+” and “-” terminals on the CNC shield. To power the Arduino Uno, use a step-down buck converter. This converter will lower the voltage from the 3S LiPo battery (12V) to the required 8V for the Arduino. Adjust the buck converter’s output voltage to 8V and connect it to the Arduino Uno’s power input.(Using DC Extension Connectors Male jack)
Add the Bluetooth Module
Connect the HC-05 Bluetooth module to the Arduino Uno. Wire it to the appropriate pins on the CNC Shield, following the HC-05’s documentation for TX, RX, and power connections.
- Connect the VCC of the Bluetooth Module to the 5V pin of the CNC Shield.
- Connect the GND of the Bluetooth Module to the GND pin of the CNC Shield.
- Connect the TXD of the Bluetooth Module to the ( End Stop Z+ ) pin of the CNC Shield.
- Connect the RXD of the Bluetooth Module to the ( SpnEn ) pin of the CNC Shield.
Connect the Stepper Motors
Wire the stepper motors to the A4988 motor drivers. Follow the specifications of the NEMA 17 motors and A4988 drivers for proper connections. Ensure the wiring is secure and that the motors are ready for control. right stepper motor connect “X” port cnc shield. left stepper motor connect “Y” port cnc shield.
Upload the Arduino Sketch
Copy the following Arduino code and paste it into the new sketch in the Arduino IDE. Select the board and port and upload the code. If this is difficult to do, watch a tutorial video. You can download the Arduino code and open it directly through the Arduino IDE. Click the Download button below to download the Arduino code
/*
=== Arduino Smart Tank Robot ===
Smartphone control via Bluetooth
by Suresh, https://robotlk.com/ , www.robotlk.com
*/
#include <SoftwareSerial.h>
#include <AccelStepper.h>
SoftwareSerial Bluetooth(11, 12); // Arduino(RX, TX) - HC-05 Bluetooth (TX, RX)
// Define the stepper motors and the pins the will use
AccelStepper LeftBackWheel(1, 2, 5); // (Type:driver, STEP, DIR) - Stepper1
AccelStepper LeftFrontWheel(1, 3, 6); // Stepper2
AccelStepper RightBackWheel(1, 7, 8); // Stepper3
AccelStepper RightFrontWheel(1, 9, 10); // Stepper4
#define led 13
int wheelSpeed = 1500;
int dataIn, m;
int lbw[50], lfw[50], rbw[50], rfw[50]; // for storing positions/steps
int index = 0;
void setup() {
// Set initial seed values for the steppers
LeftFrontWheel.setMaxSpeed(3000);
LeftBackWheel.setMaxSpeed(3000);
RightFrontWheel.setMaxSpeed(3000);
RightBackWheel.setMaxSpeed(3000);
Serial.begin(9600);
Bluetooth.begin(9600); // Default baud rate of the Bluetooth module
Bluetooth.setTimeout(1);
delay(20);
pinMode(led, OUTPUT);
}
void loop() {
// Check for incoming data
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.read(); // Read the data
if (dataIn == 0) {
m = 0;
}
if (dataIn == 1) {
m = 1;
}
if (dataIn == 2) {
m = 2;
}
if (dataIn == 3) {
m = 3;
}
if (dataIn == 4) {
m = 4;
}
if (dataIn == 5) {
m = 5;
}
if (dataIn == 6) {
m = 6;
}
if (dataIn == 7) {
m = 7;
}
if (dataIn == 8) {
m = 8;
}
if (dataIn == 9) {
m = 9;
}
if (dataIn == 10) {
m = 10;
}
if (dataIn == 11) {
m = 11;
}
if (dataIn == 12) {
m = 12;
}
if (dataIn == 14) {
m = 14;
}
// Set speed
if (dataIn >= 16) {
wheelSpeed = dataIn * 10;
Serial.println(wheelSpeed);
}
}
if (m == 4) {
moveSidewaysLeft();
}
if (m == 5) {
moveSidewaysRight();
}
if (m == 2) {
moveForward();
}
if (m == 7) {
moveBackward();
}
if (m == 3) {
moveRightForward();
}
if (m == 1) {
moveLeftForward();
}
if (m == 8) {
moveRightBackward();
}
if (m == 6) {
moveLeftBackward();
}
if (m == 9) {
rotateLeft();
}
if (m == 10) {
rotateRight();
}
if (m == 0) {
stopMoving();
}
//Serial.println(dataIn);
// If button "SAVE" is pressed
if (m == 12) {
if (index == 0) {
LeftBackWheel.setCurrentPosition(0);
LeftFrontWheel.setCurrentPosition(0);
RightBackWheel.setCurrentPosition(0);
RightFrontWheel.setCurrentPosition(0);
}
lbw[index] = LeftBackWheel.currentPosition(); // save position into the array
lfw[index] = LeftFrontWheel.currentPosition();
rbw[index] = RightBackWheel.currentPosition();
rfw[index] = RightFrontWheel.currentPosition();
index++; // Increase the array index
m = 0;
}
if (m == 14) {
runSteps();
if (dataIn != 14) {
stopMoving();
memset(lbw, 0, sizeof(lbw)); // Clear the array data to 0
memset(lfw, 0, sizeof(lfw));
memset(rbw, 0, sizeof(rbw));
memset(rfw, 0, sizeof(rfw));
index = 0; // Index to 0
}
}
LeftFrontWheel.runSpeed();
LeftBackWheel.runSpeed();
RightFrontWheel.runSpeed();
RightBackWheel.runSpeed();
// Monitor the battery voltage
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.00) * 3; // Convert the reading values from 5v to suitable 12V i
//Serial.println(voltage);
// If voltage is below 11V turn on the LED
if (voltage < 11) {
digitalWrite(led, HIGH);
}
else {
digitalWrite(led, LOW);
}
}
void runSteps() {
for (int i = index - 1; i >= 0; i--) { // Run through all steps(index)
LeftFrontWheel.moveTo(lfw[i]);
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.moveTo(lbw[i]);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.moveTo(rfw[i]);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.moveTo(rbw[i]);
RightBackWheel.setSpeed(wheelSpeed);
while (LeftBackWheel.currentPosition() != lbw[i] & LeftFrontWheel.currentPosition() != lfw[i] & RightFrontWheel.currentPosition() != rfw[i] & RightBackWheel.currentPosition() != rbw[i]) {
LeftFrontWheel.runSpeedToPosition();
LeftBackWheel.runSpeedToPosition();
RightFrontWheel.runSpeedToPosition();
RightBackWheel.runSpeedToPosition();
if (Bluetooth.available() > 0) { // Check for incomding data
dataIn = Bluetooth.read();
if ( dataIn == 15) { // If button "PAUSE" is pressed
while (dataIn != 14) { // Wait until "RUN" is pressed again
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.read();
if ( dataIn == 13) {
stopMoving();
break;
}
}
}
}
if (dataIn >= 16) {
wheelSpeed = dataIn * 10;
dataIn = 14;
}
if ( dataIn == 13) {
break;
}
}
}
}
// Go back through steps
for (int i = 1; i <= index - 1; i++) { // Run through all steps(index)
LeftFrontWheel.moveTo(lfw[i]);
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.moveTo(lbw[i]);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.moveTo(rfw[i]);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.moveTo(rbw[i]);
RightBackWheel.setSpeed(wheelSpeed);
while (LeftBackWheel.currentPosition() != lbw[i]& LeftFrontWheel.currentPosition() != lfw[i] & RightFrontWheel.currentPosition() != rfw[i] & RightBackWheel.currentPosition() != rbw[i]) {
LeftFrontWheel.runSpeedToPosition();
LeftBackWheel.runSpeedToPosition();
RightFrontWheel.runSpeedToPosition();
RightBackWheel.runSpeedToPosition();
//Serial.print(" current: ");
//Serial.println(LeftBackWheel.currentPosition());
if (Bluetooth.available() > 0) { // Check for incomding data
dataIn = Bluetooth.read();
if ( dataIn == 15) { // If button "PAUSE" is pressed
while (dataIn != 14) { // Wait until "RUN" is pressed again
if (Bluetooth.available() > 0) {
dataIn = Bluetooth.read();
if ( dataIn == 13) {
stopMoving();
break;
}
}
}
}
if (dataIn >= 16) {
wheelSpeed = dataIn * 10;
dataIn = 14;
}
if ( dataIn == 13) {
//Serial.println("DEKI");
break;
}
}
}
}
}
void moveForward() {
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.setSpeed(wheelSpeed);
}
void moveBackward() {
LeftFrontWheel.setSpeed(-wheelSpeed);
LeftBackWheel.setSpeed(-wheelSpeed);
RightFrontWheel.setSpeed(-wheelSpeed);
RightBackWheel.setSpeed(-wheelSpeed);
}
void moveSidewaysRight() {
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.setSpeed(-wheelSpeed);
RightFrontWheel.setSpeed(-wheelSpeed);
RightBackWheel.setSpeed(wheelSpeed);
}
void moveSidewaysLeft() {
LeftFrontWheel.setSpeed(-wheelSpeed);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.setSpeed(-wheelSpeed);
}
void rotateLeft() {
LeftFrontWheel.setSpeed(-wheelSpeed);
LeftBackWheel.setSpeed(-wheelSpeed);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.setSpeed(wheelSpeed);
}
void rotateRight() {
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.setSpeed(-wheelSpeed);
RightBackWheel.setSpeed(-wheelSpeed);
}
void moveRightForward() {
LeftFrontWheel.setSpeed(wheelSpeed);
LeftBackWheel.setSpeed(0);
RightFrontWheel.setSpeed(0);
RightBackWheel.setSpeed(wheelSpeed);
}
void moveRightBackward() {
LeftFrontWheel.setSpeed(0);
LeftBackWheel.setSpeed(-wheelSpeed);
RightFrontWheel.setSpeed(-wheelSpeed);
RightBackWheel.setSpeed(0);
}
void moveLeftForward() {
LeftFrontWheel.setSpeed(0);
LeftBackWheel.setSpeed(wheelSpeed);
RightFrontWheel.setSpeed(wheelSpeed);
RightBackWheel.setSpeed(0);
}
void moveLeftBackward() {
LeftFrontWheel.setSpeed(-wheelSpeed);
LeftBackWheel.setSpeed(0);
RightFrontWheel.setSpeed(0);
RightBackWheel.setSpeed(-wheelSpeed);
}
void stopMoving() {
LeftFrontWheel.setSpeed(0);
LeftBackWheel.setSpeed(0);
RightFrontWheel.setSpeed(0);
RightBackWheel.setSpeed(0);
}
Code language: PHP (php)
Download Arduino Smart Tank Robot App And Its Function
Pair your mobile device with the HC-05 Bluetooth module and open the Arduino Smart Tank Robot app. Connect to the module and start controlling your tracked robot wirelessly. The app’s interface will allow you to send commands to your robot for forward, backward, left, right, and stopping movements. For programming the automatic robot movement with this app, when we press the “SAVE” button we simply store the current positions of the stepper motors into arrays. Then when we press the “RUN” button, we call the runSteps() custom function which executes or runs through all stored steps using some for and while loops.
The Android App download
Conclusion
In conclusion, the assembly and customization of the YP100 Metal Tracked Robot Tank Chassis offer enthusiasts a comprehensive and rewarding experience in robotic exploration. By replacing the original gear motors with NEMA 17 stepper motors, integrating the CNC Shield V3 and Arduino Uno, and incorporating the HC-05 Bluetooth module, this tutorial provides a step-by-step guide for building a programmable and controllable tracked robot. The utilization of a 3D-printed part, precise wiring of stepper motors, and careful power management contribute to the robot’s stability and functionality. The inclusion of a step-down buck converter ensures optimal power supply to both the CNC Shield and Arduino Uno. Additionally, the Arduino code enables programming and customization, while the wireless control through the Arduino Smart Tank Robot app enhances the robot’s versatility. This project amalgamates hardware and software elements, fostering a deeper understanding of robotics and paving the way for further exploration and innovation in the realm of tracked robots.