Introduction: Rover 5 Tank , Arduino Outdoor Programming Challenge

Hi Guys/Gals

This project originally started to see if we could program out own remote controlled rover but turned into more then that,we ordered 3 Rover 5 units as they seems to have a very easy to use driver board form sparkfun. Below is the steps to make yours work with the use of VirtualWire library and Arduino. The code is very basic and could be done a very different way but as it is now almost anyone can understand it.

the current code allows the rover to be driver in 8 directions namely.

1) Forward
2) Reverse
3) Left
4) Right
5) Forward/Right ( drives to the right )
6) Forward/Left ( drives to the left )
7) Back/Right
8) Back/Left

See steps below to built your own !

Step 1: Step 1: Wire Up the Rover.

Attached is the manual for the driver board and description of the pin-outs and below is how to wire the Arduino Mega to the driver board.

1) Arduino Mega 2560
2) Sparkfun Rover 5 Driver board
3) Cheap 433Mhz data radio's

Mega Driver board
22 // Direction pin ch1 front right motor
28 // Direction pin ch2 front left motor
24 // Direction pin ch3 back right motor
26 // Direction pin ch4 back left motor

2 //Speed Ch1 PWM 1
3 //Speed Ch2 PWM 2
4 //Speed Ch3 PWM 3
5 //Speed Ch4 PWM 4

11 // Data Receive pin

The Rover 5 is available in 4WD or 2WD the code is written for a 4WD rover but wiring it up as below for the 2WD should still work the same.

Step 2: Step 2: Build Remote and Plug Into UNO

The Sparkfun joystick remote was an easy choice as it had n joystick and 4 buttons ( explained later )
Solder the pins onto the board. and plug it into a UNO.( presolder units is also available form them )

The data radio data pin must be connected to PIN 11 on the Uno! and POS to 5v and NEG to GND.
there are many online tutorials on the making of antenna's for the data radios but i found a 164.5mm lenght of solid copter wire gets a range of a around 42 meters.( code can be changed to use RC )

after you have done this you can find the "Rover_TX"pde attached copy ,past and upload to UNO.
NOTE( please remember you need to download and install "VirtualWire" library before the code will compile.
VirtualWire.rar

From the picture above you can see I have proceeded to make my remote smaller by using a Ariduino Pro Micro Board ( if anyone requires i will give pin layout and code but this is a very tricky and really unnecessary evil)

Step 3: Step 3: Load the Code

Attached is the two .pde's to be used drag and drop and upload if all is connected correctly you should have a working rover !!! Enjoy


Now coming back to the Buttons on the remote, our plan is to advance the code to include a pan tilt servo on the front with a IR laser acting as a "Canon" and on the other rovers have IR Receivers. this would be used with FPV gear to play real world "battle tank" . one of these function has already been implemented in the code. for example

if your rover is working. press and hold button D5 done then press the joystick down ( also a button) you should see your rover jump back ( mimic of the canon shot recoil) ;-)

this project was intended for short to medium range ( 10- 40 meters) as this is what you can expect from the cheap 433mhz data radios.

hope you guys enjoy!

Comments

author
ColinN13 made it!(author)2017-01-27

Hello, I am trying to do this project with nearly all the same equipment. However, I am getting a compile warning. I get a warning that says "typedef was ignored in this declaration." The code compiles and uploads. With the serial monitor running on the remote, I can see the values displayed by the joystick and 'case' number, but not the buttons (although they do work when wired to an LED.)


However, with the serial monitor running on the Rover, it displays nothing and is not responsive to the remote. I assume it is not receiving properly from the remote, because of the typedef struct error, which packages the information to be send by virtualwire.

Any idea why this is happening and what steps I can do to get it working? The RF links do work when I use example code for virtualwire.

author
MamunEdt made it!(author)2016-02-18

#include <AFMotor.h>

#include <LiquidCrystal.h>

//#include <Servo.h>

//Servo myservo;

LiquidCrystal lcd(32, 30, 28, 26, 24, 22);

AF_DCMotor motor1(1, MOTOR12_8KHZ);

AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

AF_DCMotor motor3(3, MOTOR34_64KHZ);

AF_DCMotor motor4(4, MOTOR34_1KHZ);

int state = 0;

int ledLight = 52;

int ledRed = 48;

int ledGreen = 46;

int BodyLight = 53;

int LdrPin = A8; // Ldr Sensore pin

int LdrValue = 0; // Ldr Sensore pin Value

//int pos = 0;

int ch1; // RC input pins

int ch2;

int ch3;

//int ledPin = 13;

//const int D1RA = 2;

//const int PWMA = 3;

const int trigPin = A11; // Sonar Sensore pins

const int echoPin = A12;

const int buttonPin = 50;

int buttonPushCounter = 0; // counter for the number of button presses

int buttonState = 0; // current state of the button

int lastButtonState = 0; // previous state of the button

int sensorpin = A10; int temperature = 0;

void setup() {

pinMode(buttonPin, INPUT);

digitalWrite(buttonPin, HIGH);

// myservo.attach(9);

pinMode(46, OUTPUT); // Light Green

pinMode(48, OUTPUT); // Light Red

pinMode(52, OUTPUT); // Light Pin

pinMode(53, OUTPUT); // Light Pin

pinMode(50, INPUT); //LDR Sensor Pin

pinMode(34, INPUT); // RC input pins

pinMode(36, INPUT);

pinMode(38, INPUT);

pinMode(trigPin, OUTPUT); // Sonar Sensore pins

pinMode(echoPin, INPUT);

pinMode(sensorpin, INPUT);

Serial.begin(9600);

Serial3.begin(9600);

lcd.begin(16, 2);

}

void LCDdisplay() {

lcd.begin(16, 2);

lcd.setCursor(4, 0); lcd.print("WELLCOME");

delay(500);

lcd.setCursor(3, 0); lcd.print("=WELLCOME=");

delay(500);

lcd.setCursor(2, 0); lcd.print("-=WELLCOME=-");

delay(1000);

lcd.setCursor(3, 1); lcd.print("<ROBOTANK>");

delay(500);

lcd.setCursor(2, 1); lcd.print("<<ROBOTANK>>");

delay(500);

lcd.setCursor(1, 1); lcd.print("<<<ROBOTANK>>>");

delay(500);

lcd.setCursor(0, 1); lcd.print("<<<<ROBOTANK>>>>");

delay(3000);

lcd.clear();

}

void Button() {

buttonState = digitalRead(buttonPin);

if (buttonState != lastButtonState) {

if (buttonState == HIGH) {

buttonPushCounter++;

Serial.println("on");

Serial.print("number of button pushes: ");

Serial.println(buttonPushCounter);

} else {

Serial.println("off");

}

delay(50);

}

lastButtonState = buttonState;

if (buttonPushCounter % 2 == 0) {

digitalWrite(ledGreen, HIGH);

digitalWrite(ledRed, LOW);

} else {

digitalWrite(ledRed, HIGH);

digitalWrite(ledGreen, LOW);

}

}

float search(void)

{

float duration = 0.00;

float CM = 0.00;

digitalWrite(trigPin, LOW); delayMicroseconds(2);

digitalWrite(trigPin, HIGH); delayMicroseconds(10); // Delay for 10 us

digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH);

CM = (duration / 58.82); //Convert distance into CM.

lcd.setCursor(11, 1); lcd.print(CM);

float distance = 0.00; distance = search();

if ((distance <= 10)) {

RobotLeft(); delay(400);

}

return CM;

}

void RightHigh()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(250);

motor2.setSpeed(250);

motor3.setSpeed(100);

motor4.setSpeed(100);

}

void LeftHigh()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(100);

motor2.setSpeed(100);

motor3.setSpeed(250);

motor4.setSpeed(250);

}

void RobotSpeedLow()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(150);

motor2.setSpeed(150);

motor3.setSpeed(150);

motor4.setSpeed(150);

}

void RobotSpeedHigh()

{

lcd.setCursor(3, 0);

lcd.print("sHi");

motor1.setSpeed(250);

motor2.setSpeed(250);

motor3.setSpeed(250);

motor4.setSpeed(250);

}

void RobotForward()

{ lcd.setCursor(0, 0); lcd.print("BK"); motor1.run(FORWARD);

motor2.run(FORWARD); // turn it on going forward

motor3.run(FORWARD);

motor4.run(FORWARD);

}

void RobotBackward()

{ lcd.setCursor(0, 0); lcd.print("FT"); motor1.run(BACKWARD);

motor2.run(BACKWARD); // the other way

motor3.run(BACKWARD);

motor4.run(BACKWARD);

}

void RobotLeft()

{ lcd.setCursor(0, 1); lcd.print("LF"); motor1.run(BACKWARD);

motor2.run(BACKWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

}

void RobotRight()

{ lcd.setCursor(0, 1); lcd.print("RT"); motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(BACKWARD);

motor4.run(BACKWARD);

}

void RobotStop()

{ motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

void LdrLight()

{ int LdrValue = analogRead(LdrPin);

if (LdrValue <= 58) {

Serial.println(LdrValue);

lcd.setCursor(7, 0);

lcd.print("ON*");

digitalWrite(ledLight, HIGH);

}

else {

digitalWrite(ledLight, LOW);

lcd.setCursor(7, 0);

lcd.print("OFF");

}

}

void Voltage()

{ int VsensorValue = analogRead(A9); float voltage = VsensorValue / 10;

lcd.setCursor(11, 0); lcd.print(voltage); lcd.print("V");

}

void Temper()

{ temperature = analogRead(sensorpin); temperature = temperature * 0.48828125;

lcd.setCursor(3, 1); lcd.print(temperature); //Show the temperature in LCD

lcd.setCursor(5, 1); lcd.print("c"); // C for Celecius

}

void Speed() {

if (ch3 >= 1000) {

Serial.println(ch3);

RobotSpeedHigh();

}

else if (ch3 <= 1000) {

Serial.println(ch3);

RobotSpeedLow();

}

}

void Blutooth()

{

if (Serial3.available() > 0) {

state = Serial3.read();

if (state == 'F' ) {

lcd.setCursor(7, 1);

lcd.print("B-F");

RobotSpeedHigh();

RobotBackward();

delay(2000);

RobotStop();

}

else if (state == 'B' ) {

lcd.setCursor(7, 1);

lcd.print("B-B");

RobotSpeedHigh();

RobotForward();

delay(1000);

RobotStop();

}

else if (state == 'L' ) {

lcd.setCursor(7, 1);

lcd.print("B-L");

RobotSpeedHigh();

RobotLeft();

delay(2000);

RobotStop();

}

else if (state == 'R' ) {

lcd.setCursor(7, 1);

lcd.print("B-R");

RobotSpeedHigh();

RobotRight();

delay(2000);

RobotStop();

}

else {

lcd.setCursor(7, 1);

lcd.print("BLT");

}

}

}

void OldRemote() {

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

//Serial.println(ch1); // each channel

// Serial.println(ch2);

// Serial.println(ch3);

if (ch2 <= 1300) {

RobotForward(); Serial.println(ch2);

}

else if (ch2 >= 1500) {

RobotBackward(); Serial.println(ch2);

}

else if (ch1 <= 1300) {

Serial.println(ch1);

RobotLeft();

}

else if (ch1 >= 1500) {

Serial.println(ch1);

RobotRight();

}

else if ((ch1 >= 1300) && (ch1 <= 1500) && (ch2 >= 1300) && (ch2 <= 1500))

{ RobotStop();

}

else {

RobotStop();

}

}

void NewRemote() {

int move; // Forward/Back speed

int back; // Turning Factor

int left;

int right;

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

move = map(ch2, 1000, 2000, -500, 500); //center over zero

move = constrain(move, -255, 255);

back = map(ch2, 1000, 2000, -500, 500);

back = constrain(back, -255, 255);

left = map(ch1, 1000, 2000, -500, 500);

left = constrain(left, -255, 255);

right = map(ch1, 1000, 2000, -500, 500);

right = constrain(right, -255, 255);

Serial.print("Channel 2:"); // Print the value of

Serial.println(right); // each channel

//Backward============

if (move >= 15) {

motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

motor1.setSpeed(move); motor2.setSpeed(move); motor3.setSpeed(move); motor4.setSpeed(move);

}

//Forward=============

else if (move <= -15) {

back = abs(move); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

motor1.setSpeed(back); motor2.setSpeed(back); motor3.setSpeed(back); motor4.setSpeed(back);

}

//Strate Left =============

else if (left >= 15) { //back=abs(move);

motor3.run(BACKWARD); motor4.run(BACKWARD);

motor3.setSpeed(left); motor4.setSpeed(left);

motor1.run(FORWARD); motor2.run(FORWARD);

motor1.setSpeed(left); motor2.setSpeed(left);

}

//Strate Right =============

else if (left <= -15) {

right = abs(right);

motor3.run(FORWARD); motor4.run(FORWARD);

motor3.setSpeed(right); motor4.setSpeed(right);

motor1.run(BACKWARD); motor2.run(BACKWARD);

motor1.setSpeed(right); motor2.setSpeed(right);

}

else {

motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

}

void NewTurn () {

int move; // Forward/Back speed

int back; // Turning Factor

int left;

int right;

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

move = map(ch2, 1000, 2000, -500, 500); //center over zero

move = constrain(move, -255, 255);

back = map(ch2, 1000, 2000, -500, 500);

back = constrain(back, -255, 255);

left = map(ch1, 1000, 2000, -500, 500);

left = constrain(left, -255, 255);

right = map(ch1, 1000, 2000, -500, 500);

right = constrain(right, -255, 255);

Serial.print("Channel 2:"); // Print the value of

Serial.println(left); // each channel

if ((move<= -40) && (left <= -40))// Back Left High

{

LeftHigh(); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

}

else if ((move<= -40) && (left >= 40))// Back Right High

{

RightHigh(); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

}

else if ((move>= 40) && (left >= 40))// Front Left High mean Right Turn

{

LeftHigh(); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

}

else if ((move>= 40) && (left <= -40))// Front Rihgt High mean Left Turn

{

RightHigh(); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

}

else {

motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

}

void Run()

{ Temper();

Voltage();

LdrLight();

Blutooth();

Speed();

Button();

}

void loop() {

NewRemote();

//digitalWrite(53, HIGH);

//NewTurn ();

}

12645086_707053422764986_8683991442674368977_n.jpg12662471_704618566341805_247849768401545546_n.jpg12512562_707053439431651_3025578540558500707_n.jpg
author
veriandrianta made it!(author)2015-02-11

how to wire the Arduino Pro Micro to the button & joystick?? please help me...

thank you very much...

veri.andrianta@gmail.com

author
Rustie0125 made it!(author)2015-02-12

Mmm. not sure what your question is? do you want to know how to map the pins so you can use a pro micro ?

author
veriandrianta made it!(author)2015-02-12

yes, i want to know how to map the pins arduino pro micro? I 've tried but, the button 1,2,3,4 not function.. thanks

author
Rustie0125 made it!(author)2015-02-12

Is your hardware setup the same as mine ? you must make sure that the pins on your Pro micro match my pins as some Pro micros are different due to different manufacturing houses

author
veriandrianta made it!(author)2015-02-13

my rover 5 tank can drive 4 direction only,,

1.forward, 2.reverse, 3.left, 4.right.

how to drive FWD/RIGHT, FWD/LEFT, REV/RIGHT, REV/LEFT??

author
MamunEdt made it!(author)2016-02-18

//PLz Follow New Turn

#include <AFMotor.h>

#include <LiquidCrystal.h>

//#include <Servo.h>

//Servo myservo;

LiquidCrystal lcd(32, 30, 28, 26, 24, 22);

AF_DCMotor motor1(1, MOTOR12_8KHZ);

AF_DCMotor motor2(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm

AF_DCMotor motor3(3, MOTOR34_64KHZ);

AF_DCMotor motor4(4, MOTOR34_1KHZ);

int state = 0;

int ledLight = 52;

int ledRed = 48;

int ledGreen = 46;

int BodyLight = 53;

int LdrPin = A8; // Ldr Sensore pin

int LdrValue = 0; // Ldr Sensore pin Value

//int pos = 0;

int ch1; // RC input pins

int ch2;

int ch3;

//int ledPin = 13;

//const int D1RA = 2;

//const int PWMA = 3;

const int trigPin = A11; // Sonar Sensore pins

const int echoPin = A12;

const int buttonPin = 50;

int buttonPushCounter = 0; // counter for the number of button presses

int buttonState = 0; // current state of the button

int lastButtonState = 0; // previous state of the button

int sensorpin = A10; int temperature = 0;

void setup() {

pinMode(buttonPin, INPUT);

digitalWrite(buttonPin, HIGH);

// myservo.attach(9);

pinMode(46, OUTPUT); // Light Green

pinMode(48, OUTPUT); // Light Red

pinMode(52, OUTPUT); // Light Pin

pinMode(53, OUTPUT); // Light Pin

pinMode(50, INPUT); //LDR Sensor Pin

pinMode(34, INPUT); // RC input pins

pinMode(36, INPUT);

pinMode(38, INPUT);

pinMode(trigPin, OUTPUT); // Sonar Sensore pins

pinMode(echoPin, INPUT);

pinMode(sensorpin, INPUT);

Serial.begin(9600);

Serial3.begin(9600);

lcd.begin(16, 2);

}

void LCDdisplay() {

lcd.begin(16, 2);

lcd.setCursor(4, 0); lcd.print("WELLCOME");

delay(500);

lcd.setCursor(3, 0); lcd.print("=WELLCOME=");

delay(500);

lcd.setCursor(2, 0); lcd.print("-=WELLCOME=-");

delay(1000);

lcd.setCursor(3, 1); lcd.print("<ROBOTANK>");

delay(500);

lcd.setCursor(2, 1); lcd.print("<<ROBOTANK>>");

delay(500);

lcd.setCursor(1, 1); lcd.print("<<<ROBOTANK>>>");

delay(500);

lcd.setCursor(0, 1); lcd.print("<<<<ROBOTANK>>>>");

delay(3000);

lcd.clear();

}

void Button() {

buttonState = digitalRead(buttonPin);

if (buttonState != lastButtonState) {

if (buttonState == HIGH) {

buttonPushCounter++;

Serial.println("on");

Serial.print("number of button pushes: ");

Serial.println(buttonPushCounter);

} else {

Serial.println("off");

}

delay(50);

}

lastButtonState = buttonState;

if (buttonPushCounter % 2 == 0) {

digitalWrite(ledGreen, HIGH);

digitalWrite(ledRed, LOW);

} else {

digitalWrite(ledRed, HIGH);

digitalWrite(ledGreen, LOW);

}

}

float search(void)

{

float duration = 0.00;

float CM = 0.00;

digitalWrite(trigPin, LOW); delayMicroseconds(2);

digitalWrite(trigPin, HIGH); delayMicroseconds(10); // Delay for 10 us

digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH);

CM = (duration / 58.82); //Convert distance into CM.

lcd.setCursor(11, 1); lcd.print(CM);

float distance = 0.00; distance = search();

if ((distance <= 10)) {

RobotLeft(); delay(400);

}

return CM;

}

void RightHigh()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(250);

motor2.setSpeed(250);

motor3.setSpeed(100);

motor4.setSpeed(100);

}

void LeftHigh()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(100);

motor2.setSpeed(100);

motor3.setSpeed(250);

motor4.setSpeed(250);

}

void RobotSpeedLow()

{

lcd.setCursor(3, 0);

lcd.print("sLO");

motor1.setSpeed(150);

motor2.setSpeed(150);

motor3.setSpeed(150);

motor4.setSpeed(150);

}

void RobotSpeedHigh()

{

lcd.setCursor(3, 0);

lcd.print("sHi");

motor1.setSpeed(250);

motor2.setSpeed(250);

motor3.setSpeed(250);

motor4.setSpeed(250);

}

void RobotForward()

{ lcd.setCursor(0, 0); lcd.print("BK"); motor1.run(FORWARD);

motor2.run(FORWARD); // turn it on going forward

motor3.run(FORWARD);

motor4.run(FORWARD);

}

void RobotBackward()

{ lcd.setCursor(0, 0); lcd.print("FT"); motor1.run(BACKWARD);

motor2.run(BACKWARD); // the other way

motor3.run(BACKWARD);

motor4.run(BACKWARD);

}

void RobotLeft()

{ lcd.setCursor(0, 1); lcd.print("LF"); motor1.run(BACKWARD);

motor2.run(BACKWARD);

motor3.run(FORWARD);

motor4.run(FORWARD);

}

void RobotRight()

{ lcd.setCursor(0, 1); lcd.print("RT"); motor1.run(FORWARD);

motor2.run(FORWARD);

motor3.run(BACKWARD);

motor4.run(BACKWARD);

}

void RobotStop()

{ motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

void LdrLight()

{ int LdrValue = analogRead(LdrPin);

if (LdrValue <= 58) {

Serial.println(LdrValue);

lcd.setCursor(7, 0);

lcd.print("ON*");

digitalWrite(ledLight, HIGH);

}

else {

digitalWrite(ledLight, LOW);

lcd.setCursor(7, 0);

lcd.print("OFF");

}

}

void Voltage()

{ int VsensorValue = analogRead(A9); float voltage = VsensorValue / 10;

lcd.setCursor(11, 0); lcd.print(voltage); lcd.print("V");

}

void Temper()

{ temperature = analogRead(sensorpin); temperature = temperature * 0.48828125;

lcd.setCursor(3, 1); lcd.print(temperature); //Show the temperature in LCD

lcd.setCursor(5, 1); lcd.print("c"); // C for Celecius

}

void Speed() {

if (ch3 >= 1000) {

Serial.println(ch3);

RobotSpeedHigh();

}

else if (ch3 <= 1000) {

Serial.println(ch3);

RobotSpeedLow();

}

}

void Blutooth()

{

if (Serial3.available() > 0) {

state = Serial3.read();

if (state == 'F' ) {

lcd.setCursor(7, 1);

lcd.print("B-F");

RobotSpeedHigh();

RobotBackward();

delay(2000);

RobotStop();

}

else if (state == 'B' ) {

lcd.setCursor(7, 1);

lcd.print("B-B");

RobotSpeedHigh();

RobotForward();

delay(1000);

RobotStop();

}

else if (state == 'L' ) {

lcd.setCursor(7, 1);

lcd.print("B-L");

RobotSpeedHigh();

RobotLeft();

delay(2000);

RobotStop();

}

else if (state == 'R' ) {

lcd.setCursor(7, 1);

lcd.print("B-R");

RobotSpeedHigh();

RobotRight();

delay(2000);

RobotStop();

}

else {

lcd.setCursor(7, 1);

lcd.print("BLT");

}

}

}

void OldRemote() {

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

//Serial.println(ch1); // each channel

// Serial.println(ch2);

// Serial.println(ch3);

if (ch2 <= 1300) {

RobotForward(); Serial.println(ch2);

}

else if (ch2 >= 1500) {

RobotBackward(); Serial.println(ch2);

}

else if (ch1 <= 1300) {

Serial.println(ch1);

RobotLeft();

}

else if (ch1 >= 1500) {

Serial.println(ch1);

RobotRight();

}

else if ((ch1 >= 1300) && (ch1 <= 1500) && (ch2 >= 1300) && (ch2 <= 1500))

{ RobotStop();

}

else {

RobotStop();

}

}

void NewRemote() {

int move; // Forward/Back speed

int back; // Turning Factor

int left;

int right;

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

move = map(ch2, 1000, 2000, -500, 500); //center over zero

move = constrain(move, -255, 255);

back = map(ch2, 1000, 2000, -500, 500);

back = constrain(back, -255, 255);

left = map(ch1, 1000, 2000, -500, 500);

left = constrain(left, -255, 255);

right = map(ch1, 1000, 2000, -500, 500);

right = constrain(right, -255, 255);

Serial.print("Channel 2:"); // Print the value of

Serial.println(right); // each channel

//Backward============

if (move >= 15) {

motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

motor1.setSpeed(move); motor2.setSpeed(move); motor3.setSpeed(move); motor4.setSpeed(move);

}

//Forward=============

else if (move <= -15) {

back = abs(move); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

motor1.setSpeed(back); motor2.setSpeed(back); motor3.setSpeed(back); motor4.setSpeed(back);

}

//Strate Left =============

else if (left >= 15) { //back=abs(move);

motor3.run(BACKWARD); motor4.run(BACKWARD);

motor3.setSpeed(left); motor4.setSpeed(left);

motor1.run(FORWARD); motor2.run(FORWARD);

motor1.setSpeed(left); motor2.setSpeed(left);

}

//Strate Right =============

else if (left <= -15) {

right = abs(right);

motor3.run(FORWARD); motor4.run(FORWARD);

motor3.setSpeed(right); motor4.setSpeed(right);

motor1.run(BACKWARD); motor2.run(BACKWARD);

motor1.setSpeed(right); motor2.setSpeed(right);

}

else {

motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

}

void NewTurn () {

int move; // Forward/Back speed

int back; // Turning Factor

int left;

int right;

ch1 = pulseIn(34, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(36, HIGH, 25000); // each channel

ch3 = pulseIn(38, HIGH, 25000);

move = map(ch2, 1000, 2000, -500, 500); //center over zero

move = constrain(move, -255, 255);

back = map(ch2, 1000, 2000, -500, 500);

back = constrain(back, -255, 255);

left = map(ch1, 1000, 2000, -500, 500);

left = constrain(left, -255, 255);

right = map(ch1, 1000, 2000, -500, 500);

right = constrain(right, -255, 255);

Serial.print("Channel 2:"); // Print the value of

Serial.println(left); // each channel

if ((move<= -40) && (left <= -40))// Back Left High

{

LeftHigh(); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

}

else if ((move<= -40) && (left >= 40))// Back Right High

{

RightHigh(); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD);

}

else if ((move>= 40) && (left >= 40))// Front Left High mean Right Turn

{

LeftHigh(); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

}

else if ((move>= 40) && (left <= -40))// Front Rihgt High mean Left Turn

{

RightHigh(); motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD);

}

else {

motor1.run(RELEASE);

motor2.run(RELEASE);

motor3.run(RELEASE);

motor4.run(RELEASE);

}

}

void Run()

{ Temper();

Voltage();

LdrLight();

Blutooth();

Speed();

Button();

}

void loop() {

NewTurn ();

}

author
veriandrianta made it!(author)2015-02-13

yes, my hardware setup the same as you.

1. arduino mega 2500

2. arduino pro micro 32u4

3. driver rover 5 tank

4. cheep data radio 433MHz

20150214_071222.jpg20150214_071811.jpg20150214_071730.jpg
author
Rustie0125 made it!(author)2015-02-16

Easiest way to test is to see what your default analog values are from the joystick. load the code on the remote control device and open the serial monitor while it is running the joystick will give you values of around 512 or close if these values are out you will not get all 8 directions only 4. as for the buttons, you can see the buttons in the serial monitor aswell, if they work and you press the button the string will show "1" in the 3, 4 and 5 position.

author
veriandrianta made it!(author)2015-02-13

thank you very much for your help

author
veriandrianta made it!(author)2015-02-13

Is it like this way of connecting the push button??

MAP PIN PUSH BUTTON.png
author
JamieC6 made it!(author)2015-04-05

Hi awesome project, just a quick question.

Can you show me how to wire the Transmitter to the Joystick board with the Uno plugged in. Thank you.

author
JamesM1 made it!(author)2015-03-10

Hi,great project! I would like the pin out for the Pro?

Thanks

About This Instructable

10,524views

39favorites

License:

More by Rustie0125:LED Head Arduino TED Arduino Integer transmission simplified Arduino low Power Project.
Add instructable to: