SPY Robot Using Arduino With Bluetooth Controls

Hey techies, welcome back to Mechatronic. Do you know what a SPY robot is? Well in this article we are going to make a SPY robot using Arduino which can be controlled using Bluetooth and we can also see the live camera view on the app. For capturing the video we fixed a smartphone in the front section of the SPY robot. We are using an Arduino UNO microcontroller and HC-05 Bluetooth module in this project. Click to view how an HC-05 Bluetooth module works with Arduino. You can check out more amazing projects based on Arduino. Also, check the mobile phone control SPY robot made by us.

How Does SPY robot using Arduino Work?

This SPY robot can move in the left, right, forward and backward directions. We are controlling its movement through an android app which is also developed by us. It is called a SPY robot using Arduino as we can see the live view in front of it on the screen of the controlling app. For capturing the live view we attach a smartphone in front of it. Through the IP Webcam android application, we can send the captured scenes to the controller app. The robot will move according to the actions taken by you in the application. First, you have to connect your device to Bluetooth and then to the camera with the help of the generated IP address. This robot is very useful as it can provide you with a live view of such places where a human cant reach. It is also very helpful to go under the bed or the small corners in your home so you can find your lost stuff. To connect with Bluetooth please refer to the images given below.

spy robot using arduino

spy robot using arduino

Smartphone Applications Used in the Project

We are using the SPY Control Robot app developed by us to control the movement and see the live video of the SPY robot. The app controls the robot with the help of Bluetooth. You have to connect the Bluetooth by clicking BT Connect on the app. Now you can move the robot in different directions but there is no live video streaming in the app. Here is a screenshot of the SPY Control Robot app without a camera.

You have to enter the camera IP and then click on the cam connect to set up the camera connectivity. When you have successfully connected to the camera then the live view in front of the SPY robot starts streaming on the app. You can see the screenshot of our mobile’s screen.

spy robot using arduino

You have to install the IP Webcam application on the smartphone you are going to fix in the robot’s body. By using this application we can get a live view from the phone’s camera and we see it on the SPY Control Robot app. You can download the IP Webcam app here.

Install this app on your device and open it. Scroll down in the app and click on start server to generate a unique IP address. Some screenshots are given below for your reference.

Now you can see an IP address on the screen given below. Here the IP is 192.168.0.105. You have to enter this id into the camera id section of the controller app. The live streaming of the video starts playing on the controller app. Make sure you are connected to a fast speed internet connection to avoid buffering and delays.

Components Required

  • Arduino UNO
  • HC-05 Bluetooth module
  • Jumper Wires
  • 9v battery
  • Four gear motors with wheels
  • L298n Motor driver module
  • USB cable for uploading the code
  • Switch
  • Two smartphones with a good internet connection

Circuit Diagram of the SPY robot using Arduino

spy robot using arduino

Please make the connections according to the diagram given above.

+5 volts of Arduino -> VCC of Bluetooth, +5v of l298n

GND of Arduino -> GND of Bluetooth, GND of l298n

+12v of l298n -> positive of 9 volts battery with a switch as shown

Positive of two motors -> out 2 of l298n

Negative of two motors -> out 3 of l298n

Positive of two motors -> out 3 of l298n

Negative of two motors -> out 3 of l298n

ENA of l298n -> digital-10 of Arduino

IN1 of l298n -> digital-9 of Arduino

IN2 of l298n -> digital-8 of Arduino

IN3 of l298n -> digital-7 of Arduino

IN4 of l298n -> digital-6 of Arduino

ENB of l298n -> digital-5 of Arduino

TX of Bluetooth -> digital-2 of Arduino

RX of Bluetooth -> digital-3 of Arduino

Code for SPY robot using Arduino Project

NOTE: Please upload the given code to the Arduino. Before uploading you have to install <SoftwareSerial.h> library for proper compilation of the code. If you don’t know how to install a zip library to the Arduino IDE application then check it here.

 // Techatronic.com  
 // Download Library of SoftwareSerial link given  
 // https://github.com/PaulStoffregen/SoftwareSerial  
 #include <SoftwareSerial.h>  
 SoftwareSerial SoftSerial(2,3); // SoftSerial( RX , TX );  
 // 2 pin connect to TX of HC-05 Bluetooth  
 // 3 pin connect to RX of HC-05 Bluetooth  
 int Speed = 130;   
 int mode=0;  
 void setup()  
 {  
   Serial.begin(9600);   // buart rate  
   SoftSerial.begin(9600);  
   pinMode(4,OUTPUT);  // LED Pin  
   pinMode(5,OUTPUT);  // LED Pin  
   pinMode(6,OUTPUT);  // LED Pin  
   pinMode(7,OUTPUT);  // LED Pin  
   pinMode(9,OUTPUT);  // MOTOR Pin  
   pinMode(10,OUTPUT);  // MOTOR Pin  
   pinMode(11,OUTPUT);  // MOTOR Pin  
   pinMode(12,OUTPUT);  // MOTOR Pin  
 }  
 void loop()  
 {  
  if (SoftSerial.available()>0)  
    {  
       int data = SoftSerial.read();  
       Serial.println(data);  
     if(data== 1 )     // FORWARD DIRECTION  
     {  
     digitalWrite(4,HIGH); // LED ON  
     digitalWrite(5,LOW);  // LED OFF  
     digitalWrite(6,LOW);  // LED OFF  
     digitalWrite(7,LOW);  // LED OFF  
     digitalWrite(9,HIGH);  // MOTOR HIGH  
     digitalWrite(10,LOW);  // MOTOR LOW  
     digitalWrite(11,LOW);  // MOTOR LOW  
     digitalWrite(12,HIGH); // MOTOR HIGH  
     }  
     if(data== 3 )     // LEFT DIRECTION  
     {  
     digitalWrite(4,LOW);  // LED OFF  
     digitalWrite(5,HIGH); // LED ON  
     digitalWrite(6,LOW);  // LED OFF  
     digitalWrite(7,LOW);  // LED OFF  
     digitalWrite(9,HIGH);  // MOTOR HIGH  
     digitalWrite(10,LOW);  // MOTOR LOW  
     digitalWrite(11,HIGH); // MOTOR HIGH  
     digitalWrite(12,LOW);  // MOTOR LOW  
     }  
     if(data== 4 )     // RIGHT DIRECTION  
     {  
     digitalWrite(4,LOW);  // LED OFF  
     digitalWrite(5,LOW);  // LED OFF  
     digitalWrite(6,HIGH); // LED ON  
     digitalWrite(7,LOW);  // LED OFF  
     digitalWrite(9,LOW);  // MOTOR LOW  
     digitalWrite(10,HIGH); // MOTOR HIGH  
     digitalWrite(11,LOW); // MOTOR LOW  
     digitalWrite(12,HIGH); // MOTOR HIGH  
     }  
     if(data== 2 )     // BACKWARD DIRECTION  
     {  
     digitalWrite(4,LOW);  // LED OFF  
     digitalWrite(5,LOW);  // LED OFF  
     digitalWrite(6,LOW);  // LED OFF  
     digitalWrite(7,HIGH); // LED ON  
     digitalWrite(9,LOW);  // MOTOR HIGH  
     digitalWrite(10,HIGH); // MOTOR LOW  
     digitalWrite(11,HIGH); // MOTOR LOW  
     digitalWrite(12,LOW); // MOTOR HIGH  
     }  
     if(data== 5 )     // STOP DIRECTION  
     {  
     digitalWrite(4,LOW);  // LED OFF  
     digitalWrite(5,LOW);  // LED OFF  
     digitalWrite(6,LOW);  // LED OFF  
     digitalWrite(7,LOW);  // LED OFF  
     digitalWrite(9,LOW);  // MOTOR HIGH  
     digitalWrite(10,LOW); // MOTOR LOW  
     digitalWrite(11,LOW); // MOTOR LOW  
     digitalWrite(12,LOW); // MOTOR HIGH  
     }  
    }  
 }  

We hope that you learn to make the SPY robot by reading this article. Now try to make it on your own. If you are facing any errors then do inform us in the comments section below. Also, you can check out more tutorials on Arduino and Raspberry Pi written by us.

HAPPY LEARNING!