• EUR€
  • £GBP
  • $USD

Devastator Tank with Camera

DFRobot Mar 03 2016 1121

 Want to take a peep at your friend but feel lazy to go over? This devastator tank with camera is here to help!

You can even use it to explore places that people cannot go, such as.... the surface of Mars...lol

The Devastator tank mobile platform and Romeo BLE microcontroller provides the robot with excellent mobility.  With the universal Bluetooth 4.0 module integrated on the Romeo BLE microcontroller, there are tons of ways to customize your own controlling mechanism. Here I use the GoBLE iPhone App to control the robot. It’s free and easy to use. 

We have a 2DOF tilt'n turn camera mount installed on the top of the robot to control the orientation of the camera.
The Webcam I used on the robot connects to computer via Bluetooth. 


1.The left motor connects to M2 and the right motor connects to M1. (pay attention to the poles)
2. Motors need separate power supply. Power input port locates next to the motor output port. switch OFF the board first and then connect the battery to this port.
3. Connect the upper servo of the mount to pin D8.
4. Connect the lower servo of the mount to pin D9.
5. Install the camera on the mount and power it up.
6. Connect the Bluetooth receiver of the camera to computer. 
Program#include <Servo.h> #include <Metro.h> #include "GoBLE.h" int speedPin_M1 = 5;     int speedPin_M2 = 6;     int directionPin_M1 = 4;     int directionPin_M2 = 7;     Servo base; Servo top; int basePosition = 90; int topPosition = 115;   int joystickX, joystickY; int buttonState[5]; void setup() {  Goble.begin();  Serial.begin(115200);  top.attach(9);          base.attach(8);      top.write(topPosition);    base.write(basePosition); } void loop() {  if (Goble.available()) {    joystickX = Goble.readJoystickX();    joystickY = Goble.readJoystickY();    buttonState[SWITCH_UP]     = Goble.readSwitchUp();    buttonState[SWITCH_DOWN]   = Goble.readSwitchDown();    buttonState[SWITCH_LEFT]   = Goble.readSwitchLeft();    buttonState[SWITCH_RIGHT]  = Goble.readSwitchRight();    //    Serial.print("Joystick Value: ");    //    Serial.print(joystickX);    //    Serial.print("  ");    //    Serial.println(joystickY);    if (joystickY > 196) {      Serial.println("turn right");      carTurnRight(250, 250);    }    else if (joystickY < 64) {      Serial.println("turn left");      carTurnLeft(250, 250);    }    else if (joystickX > 196) {      Serial.println("move forward");      carAdvance(500, 500);    }    else if (joystickX < 64) {      Serial.println("move backward");      carBack(500, 500);    }    else {      carStop();    }    if (buttonState[SWITCH_LEFT] == PRESSED &&        buttonState[SWITCH_RIGHT] == RELEASED) {      Serial.println("servo left");      Serial.println(basePosition);      basePosition += 5;      if (basePosition >= 180) {        basePosition = 180;      }    }    else if (buttonState[SWITCH_RIGHT] == PRESSED &&             buttonState[SWITCH_LEFT] == RELEASED) {      Serial.println("servo right");      Serial.println(basePosition);      basePosition -= 5;      if (basePosition <= 0) {        basePosition = 0;      }    }    else if (buttonState[SWITCH_UP] == PRESSED &&             buttonState[SWITCH_DOWN] == RELEASED) {      Serial.println("servo forward");      Serial.println(topPosition);      topPosition -= 5;      if (topPosition <= 70) {        topPosition = 75;      }    }    else if (buttonState[SWITCH_DOWN] == PRESSED &&             buttonState[SWITCH_UP] == RELEASED) {      Serial.println("servo back");      Serial.println(topPosition);      topPosition += 5;      if (topPosition >= 160) {        topPosition = 155;      }    }    top.write(topPosition);    base.write(basePosition);  } } void carStop() {                //  Motor Stop  digitalWrite(speedPin_M2, 0);  digitalWrite(directionPin_M1, LOW);  digitalWrite(speedPin_M1, 0);  digitalWrite(directionPin_M2, LOW); } void carTurnLeft(int leftSpeed, int rightSpeed) {       //Turn Left  analogWrite (speedPin_M2, leftSpeed);             //PWM Speed Control  digitalWrite(directionPin_M1, HIGH);  analogWrite (speedPin_M1, rightSpeed);  digitalWrite(directionPin_M2, LOW); } void carTurnRight(int leftSpeed, int rightSpeed) {     //Turn Right  analogWrite (speedPin_M2, leftSpeed);  digitalWrite(directionPin_M1, LOW);  analogWrite (speedPin_M1, rightSpeed);  digitalWrite(directionPin_M2, HIGH); } void carBack(int leftSpeed, int rightSpeed) {           //Move backward  analogWrite (speedPin_M2, leftSpeed);  digitalWrite(directionPin_M1, LOW);  analogWrite (speedPin_M1, rightSpeed);  digitalWrite(directionPin_M2, LOW); } void carAdvance(int leftSpeed, int rightSpeed) {         //Move forward  analogWrite (speedPin_M2, leftSpeed);  digitalWrite(directionPin_M1, HIGH);  analogWrite (speedPin_M1, rightSpeed);  digitalWrite(directionPin_M2, HIGH); }Code analysis:
To get this working, you need to import and include libraries for GoBLE app and Bluno Motor drive. Click here to download these libraries. 
Global variable and Setup() function are for initiating motor, servo and GoBLE Bluetooth communication.
I would like to explain these two lines:
int basePosition = 90;
int topPosition = 115;
Orientation of the camera is controlled by positions of servos. I set upper and lower servos to be 115 and 90 degree to set the camera facing straight ahead. Calibration maybe needed due to difference installation.
In Loop() function, we detect the GoBLE’s signal first and then read the data of Joystick and button. In GoBLE, we use the joystick on the left side to control the  movement and buttons on the right side to control the camera’s orientation.

For the Joystick setup, as Y  and X represents horizontal and vertical position respectively. and  The value of the position ranges from 0 to 255. We set the threshold value to be 64 and 194 to determine whether the vehicle travels straight or makes turns.
For button setup, “up and down” bottons are set to control vertical angle of the cameraand the “left and right” bottoms are set to control its horizontal angle. each single tap on the botton turns the camera for 5 degree. The vertical angle can only be set between 75 and 155 and the horizontal angle is between 0 and 180.
Finally, we also need to add 5 functions corresponding “forward, backword, turn left, turn right and stop” movements. These motions are realized by controlling the direction and speed of each motor. 
Video transmission
 you may need the “VIDEOVIEW” to view image captured by the camera.

Make sure the bluetooth receiver is connected to computer. Then start VIDEOVIEW and pair Devices. Then, the image can be transmitted from the camera.