How to Make a Smart Phone Controlled Robot? Complete Step by Step Instructions

| |

The path to an Off-Road Robot – Our last two projects – The Spinel Crux V1 and The Spinel Crux L2 have been Revolutionary success within and outside our community. We built a gesture-controlled robot and we made an addon –  a robotic arm and fixed on top of it. Our project secured the first position in various competitions and found its way on the front pages of various magazines.

This time, we decided to make our hands dirty. We build a Smart Phone Controlled Robot, which can travel through rough terrain and can be remotely controlled using a mobile phone or a laptop.

Smart Phone Controlled Robot using Arduino

Smart Phone Controlled Robot using Arduino

In this post, I will be showing you how to make this awesome Mobile phone controlled Robot controlled using Arduino and WiFi. Here I will be giving you complete details including the circuit diagram, the PCB layout if you want to make a PCB, and complete codes for you to make your own robot. Just like the previous video, I will try to make this video as simple as possible so that you can understand everything easily in a fun way.


Design your own PCBs for your Pet Project! Try out Altium PCB Designer


Video Demo

Here is a demo video of the badland brawler to a get a taste of it.

How to Make a Smart Phone Controlled Robot?

Here, what we are going to do is, we will be making a circuit that will receive data from the mobile phone and drive the motors connected to the robot.

Get Your Components

Click on them to purchase from amazon

Getting Started with Robotics?

Want to learn Robotics from Scratch? Here is an awesome guide for you to get started with robotics (Free Video Tutorials Included).

WiFi Robot using Arduino

Step 1 – Robot Chassis

This is a cool Robot chassis I found online. This one has 4 huge wheels connected to 4 DC Motors. The mud tires are strong and provide enough friction between the tire and the ground which enables this bot to climb through rough and slippery dirt roads or rocks without much effort. you will find the link in the description.

Chassis Kit Assembly Video

Step 2 – Circuit

This is the circuit. You can try it out on a breadboard and once you are done, you can use it as such for the project or make your own PCB. I personally like PCBs. PCBs are neat and help to get rid of all nasty wires hanging around. And it’s cool to make your own PCBs for your project right?

Drawing Schematics and PCB Design using Altium

Altium Announces Major Update to Flagship PCB Design Tool at Annual  Conference

So I used Altium Designer to draw the circuit and design the PCB. It is a powerful tool that can be used to design and create your own PCBs for your project as well as complex and multiplayer PCBs for industrial use. Here is the link to Altium trial version.

Here, I have designed a PCB layout where you can easily mount your Arduino Nano 33 IOT , L293D ICs and the supporting components and set this up without using messy wires and cables hanging around. The board is lightweight and can be powered using a 9V battery or a 9-12 V power adapter.

Schematics in Altium

Powering Up

Here, I have designed a PCB layout where you can easily mount your Arduino Nano 33 IOT , L293D ICs and the supporting components and set this up without using messy wires and cables hanging around. The board is lightweight and can be powered using a 9V battery or a 9-12 V power adapter.

We need to power up the whole circuit and drive all 4 motors using L293D/L298N motor driver and our Arduino board. We need a powerful source that can provide enough current. So, I decided to go with a 12V LiPo battery.

The input power is connected to a 7805 regulator. 7805 is a 5V regulator which will convert an input voltage of 7- 32V to a steady 5V DC supply. There are indicator LEDs across various points for easy troubleshooting.

You can either power your Arduino using 12V or regulated 5V output from the 7805 regulator. You can select that using a jumper.

Powering Arduino depends upon the type of board you are using. Here I am using an Arduino Nano 33 IOT which can withstand a voltage of 12V in its Vin pin. It’s not the case with all the boards. If I am connecting this 12 V directly, it may fry the chip. So, If you want, you can use a voltage regulator to step down the voltage to 5V before feeding it to Arduino.

Driving Motors

You can easily drive the DC motors using a simple H Bridge circuit or a motor driver. In this project, I will be using  L293D. These DC motors draw huge amounts of current and we have 4 of them. So I will be using 2 L293d in a piggyback configuration, it simply means connecting them in parallel. This will double the current and enables you to control two set of DC motors at the same time.If you are not sure about piggybacking L293d and doubling the output current, make sure you check this video.

Once you are done drawing the circuit, you can make the PCB layout like this. The layout is ready guys. You will find the Gerber File here.

PCB Designed using Altium

Step 3 – Ordering The PCB

Go to JLCPCBs website and Click on “Quote Now” and upload your Gerber File.

Make a Smart Phone Controlled Robot? Complete Step by Step Instructions - An Off Road, 4 Wheel Drive Robot using Arduino.

Once the Gerber file is uploaded, it will show you a preview of your circuit board. Make sure this is the PCB Layout of the board you want. Below the PCB preview, you will see so many options such as PCB Quantity, Texture, Thickness, Color etc. Choose all that are necessary for you.

jlcpcb assembly review - Online PCB Manufacturer

Once everything is done, click on “Save To Cart”. In the next page, you can choose a shipping and payment option and Check Out Securely. You can either use Paypal or Credit/Debit Card to pay.

The PCB will be manufactured and shipped within days and will be delivered to your doorstep within the mentioned time period. Once you get all the components, it’s time for you to solder them together. Solder all the components onto the board and make sure to check the polarity of the components.

Step 4 – Connect RC Monster Truck to The Network

Like I mentioned earlier, this Robot is controlled using an Android Smart phone using WiFi. This is similar to our WiFi Robot using Arduino which I published a month ago. Inorder to control our robot, it should be connected to an active WiFi network. You can either use your home WiFi network or, like I did, you can create a hotspot on your smartphone.

Step 5 – Coding the RC Rock Crawler

Download the below code to your Badland Brawler Off-road Robot.[AdSense-B]

#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
char ssid[] = "RootSaid"; //WiFi Network Name
char pass[] = "WiFi Password"; //WiFi Network Password
int keyIndex = 0;    
unsigned int localPort = 5005; 

char packetBuffer[256]; 
char  ReplyBuffer[] = "acknowledged"; 

WiFiUDP Udp;

void setup() {
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
  Serial.begin(9600);


  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);

    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("nStarting connection to server...");
  Udp.begin(localPort);
}

void loop() {

  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
   Serial.print(remoteIp);
    Serial.print(", port ");
   Serial.println(Udp.remotePort());

    int len = Udp.read(packetBuffer, 255);
    if (len > 0) {
      packetBuffer[len] = 0;
    }
    Serial.print("Command Received: ");
    Serial.println(packetBuffer);


 if(strcmp(packetBuffer, "forward") == 0)
    {
forward();
    }
 else if(strcmp(packetBuffer, "left") == 0)
    {
left();
    }
 else if(strcmp(packetBuffer, "right") == 0)
    {
right();
    }
 else if(strcmp(packetBuffer, "backward") == 0)
    {
backward();
    }
else if(strcmp(packetBuffer, "stop") == 0)    {
stopp();
    }

Serial.println("");
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void forward()
{
  analogWrite(2, 254);
  analogWrite(3, 254);

  digitalWrite(5,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
}

void backward()
{
  analogWrite(2, 254);
  analogWrite(3, 254);

  digitalWrite(5,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(6,HIGH);
  digitalWrite(7,LOW);
}

void left()
{
  analogWrite(2, 254);
  analogWrite(3, 10);

  digitalWrite(5,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
}
void right()
{
  analogWrite(2, 10);
  analogWrite(3, 254);

  digitalWrite(5,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
}

void stopp()
{
  analogWrite(2, 20);
  analogWrite(3, 254);

  digitalWrite(5,LOW);
  digitalWrite(4,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
}

Connect your Arduino board to your PC. Once you finish downloading the code, open it using Arduino IDE. There you have to make a small change in the below code

This is our code. Download this code, you will find the link in the description.

Connect your Arduino board to your PC. Once you finish downloading the code, open it using Arduino IDE. There you have to make a small change in the below code

char ssid[] = "RootSaid"; //WiFi Network Name
char pass[] = "WiFi Password"; //WiFi Network Password

This is where you enter the ESSID and Passphrase of your network. Before uploading, make sure that you change values to SSID and Passphrase of your WiFi network.5005 is the port, Arduino will be listening for incoming UDP Packets. There are 6 pins we will connecting to the motor driver input

Then, it connects to the WiFi network using predefined ESSID and Passphrase and set up a UDP listener in the predefined port. Then it save the UDP packet contents to the variable ‘packetBuffer’ and print its value.

Then, we drive the robot depending upon the packets received.

Once that is done, click on tools, choose the right port and board and click on the upload button. .

Once the code is uploaded, fire up the serial monitor. This will show you the IP Address of the Aruino

Step 6 – Install RootSaid WiFi Command Center from Google PlayStore

Thats it!! All the hard work is done. That wasnt so hard, was it? Now all you have to do is download and install an App from playstore.

RootSaid WiFi Command Center is an android mobile phone app that can be used to control robots as well as home appliances over WiFi.

All you have to do is start the App, enter the IP address and Port of the listener (the Arduino board of your RC Monster Truck), go the Robot Controller tab and control it using the arrow button in your android smart phone.

Click Here to Download this app to your phone from Playstore.

Step 7 – Start

BadLand Brawler is now set and ready to go.

Now all you have to do is fire up the App in your android smart phone, enter the IP address of the robot and port it is listening to.

Load the IP and Port using the link button and navigate to the Robot Controller Tab.

Now you can control your RC Off Road Robot by simply pressing the forward, backward, left and right buttons in your android smart phone.

Whats Next?

This is not over yet. We are now adding Addons such as servo motors and sensors to this Off Road bot and we are making more powerful and intelligent.[AdSense-C]

Here is a list of Cool Raspberry Pi projects you can do.

Interested in more Awesome electronics Projects? Join our Family and be a part of Great innovative ideas and designs.

Click Here to join our community.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *