Introduction: Laptop Controlled Robot V2.0

Arduino is a great thing unless you know how to use it. But when both bluetooth and arduino come into play, its even more fun.So here presenting you another great project that uses arduino as its brain and bluetooth for communications. This is a new version of my previous project - Laptop controlled robot v1.0. As it is clear from the name, this robot can be controlled through a laptop or pc that has blutooth in it. Since bluetooth is also present in android phones, the robot can be also controlled using it. This robot is so talented that it can tell you the temperature of its surroundings, the distance, how far an obstacle is present and the image of surroundings through a camera. As this is a new version, many changes are made and new features are added that makes it even better. But the question comes that how does this work?

The project uses an arduino which is connected to a bluetooth module which produces a wireless connection between a laptop and the arduino. So when we press a button on our laptop, data is sent through bluetooth present in the laptop and received through the bluetooth module present in the robot. The data is then transmitted to arduino which is programmed is such a way to accept the data, process it and perform a task mentioned under that type of data. For eg. if you press a button that moves the robot forward, the arduino receives the command through bluetooth and sets two of the pins high as it is programmed to do so. The signal is then transmitted to the motor driver ic which conducts current to both the motors and the robot moves forward. Not only bluetooth but other forms of connectivity such as wifi, internet can also be used here.

Here are the upgrades and changes made in the robot as compared to the previous one:

  1. Uses an Arduino nano instead of uno which saves space and reduces the cost.
  2. Is powered by a battery pack rated at 8v and 1.0Ah unlike the previous one which used a large and heavy 12v battery. The batteries are cheap, small and light.
  3. Uses only two motors instead of four which again reduces cost and saves power. The front wheels are supported by a metal shaft.
  4. Uses a completely soldered circuit while the previous one used breadboard for connections so the chances of the circuit not working are less.
  5. Has an added temperature sensor that can tell you the temperature of the robot's surroundings.
  6. Has an added ultrasonic sensor that tells the distance in centimeters and how far an obstacle is present.
  7. Has a liquid crystal display to display texts, temperature, distance and data.
  8. Has added blue led neon lights that add looks to the robot at night.
  9. Has added buzzer which acts as a horn for the robot.
  10. Has a clamp that can hold a phone which can act as a wireless camera connected to the laptop.

__________

Update:

It's not easy to reply to each and every comment on so many instructables, so you can ping me for any assistance/discussion/query. My email address is: agarwalsanyam946@gmail.com

For more such awesome DIYs, subscribe to my YouTube channel.

My Facebook page: Make w/ SA

Get the best of the parts at reasonable rates from GearBest.

Also, have a look at their ongoing sales:

The Fall 3D Printer and Electronic Tools Promotional Sale

Arduino Best Deals

Creality3D CR - 10 3D Printer (coupon: GBCR10J) $396.99

Step 1: Parts and Tools

The following parts are required to make this robot. The total cost of the project was around $45 or 2700 INR. Most of the parts can be obtained from your local hobby store or over online stores.


PARTS:

  • 1x Arduino nano
  • 1x Liquid Crystal Display (16x2)
  • 1x Bluetooth Module (HC-05)
  • 1x Ultrasonic sensor
  • 1x LM35 temperature sensor
  • 1x L293D motor driver IC
  • 1x 16 pin IC socket
  • 2x 4v 1.0ah sealed lead-acid batteries
  • 2x 100 rpm geared motors
  • 4x Wheels
  • 1x Shaft (10cm)
  • 1x Chassis
  • 6x LEDs
  • 1x Piezo buzzer (will be used as a horn)
  • Perfboard
  • Rainbow cable
  • Female headers
  • Male headers

TOOLS:

  • Soldering iron
  • Soldering wire
  • Wire cutter/stripper
  • Hot glue gun w/glue sticks
  • Screwdriver
  • Double sided tape

Step 2: Mount the Motors

Start by mounting the motors on the chassis as shown in the image above. You can use any type of base such as aluminium, wood, plastic or you could even make your own. Use clamps to mount the motors if you're not using a similar kind of base.

Step 3: Add the Front and Back Wheels

Since this is a two-wheeled robot, you need to connect a shaft to make the front wheels move along with the back wheels. You can also use a ball bearing but wheels would look much better. A mistake which was done in the first version was that it used wheels of different sizes which caused problems which is corrected here. So don't do that mistake. Fix the wheels in place using screws.

Step 4: Make a Shield for Arduino

You would not want to solder your arduino to a pcb, so you need to make a shield which allows your arduino to be plugged in and out easily when you need it for other projects.

So using some female headers, solder a shield to the perfboard. Check if your arduino can be plugged in and out easily.

Step 5: Connect the Temperature Sensor

Connect the temperature sensor to the board according to the schematic above or the text below. I would recommend not to solder it directly but use some female headers.

  1. Sensor pin vcc ---- Arduino +5v
  2. Sensor pin vout ----- Arduino pin A0
  3. Sensor pin gnd ----- Arduino gnd

Step 6: Connect the BT Module

Solder some female headers to the board with a 1.2K and 2.2K resistor. Connect it to arduino according to the schematic. The resistor act as voltage dividers that prevent excess voltage to enter the BT module.

Connect the vcc of BT module to arduino 3.3v for HC-05 or to 5v for any other module. Mine had an inbuilt voltage regulator so connected it to 5v. Look at the voltage rating given on the module.

Step 7: Choose Your Motor Driver

A crucial part in the making of this project is choose your motor driver. There are plenty of options available and since the motors do not consume high power, you can easily select any one of them which would not be cheap and big. To save money, instead of buying a motor driver shield you can just buy the motor driver and make your own shield. It is very easy to connect it to arduino here. In this case the best option should be the most widely used motor driver ic, l293d which is cheap and can supply enough power to drive the motors used in this project. It can drive motors that move on 36v or less. Another advantage is that it is a dual h-bridge ic allowing you to drive two motors in the same package. Another option can be l298 that is more expensive but can drive higher power motors that run on 46v or less. Check out the list below of motor driver ics by sanken electronics.

The need for a motor driver here is that the output current of arduino is very less which is not enough to power a motor. It can only drive leds, buzzers or devices that require less current to operate. The motor driver ic acts as a transistor here that amplifies the small current supplied by arduino to give a large amount of current which is enough to power a motor. The input given can be analog as well as digital which means that the current supplied to it is directly proportional to the output current which is used to control the speed to motors that is added as a new feature to this robot.

Step 8: Connect the Motor Driver

After choosing the motor driver connect it to arduino according to the following. The connections are for l293d. For connecting l298, refer to this instructable.

  1. IC pins 1,8,9,16 ----- Arduino Vin
  2. IC pins 4,5,12,13 ---- Arduino gnd
  3. IC pin 2 ---- Arduino pin D5
  4. IC pin 7 ---- Arduino pin D6
  5. IC pin 15 ---- Arduino pin D9
  6. IC pin 10 ---- Arduino pin D10

Step 9: Connect the Liquid Crystal Display

This a new addition to the robot which shows the temperature and distance. Connect it according to the text below. I added a switch for the backlight.

  1. Pins 1,5,16 ---- Arduino gnd
  2. Pin 2 ---- Arduino 5v
  3. Pin 15 ---- Arduino 5v w/100 ohm resistor
  4. Pin 4 ---- Arduino pin D11
  5. Pin 6 ---- Arduino pin D8
  6. Pin 11 ---- Arduino pin D7
  7. Pin 12 ---- Arduino pin D4
  8. Pin 13 ---- Arduino pin D3
  9. Pin 14 ---- Arduino pin D2

Step 10: Connect the Motor to the Driver

Connect the motors to the IC by soldering some male headers to the ic. The reason why I added headers was to easily switch the wires in case I connected them wrong. To check the polarity of motors, connect them to a battery in either way. If it turns clockwise, that means the polarity is the same as the battery is connected and vice-versa.

Connect the positive of right motor to pin 3 and negative to pin 6. Connect the positive of left motor to pin 11 and negative to pin 14. Make sure you connect them in the right way.

Step 11: Connect the Front Lights

Like the previous version, this one also has LEDs that increase the looks of the robot. While the previous version used, 5mm LEDs which had a lens, this one uses dome LEDs that transmitt their light over a large area. These LEDs also help to look through the camera when the robot is moving in dark.

Connect two white LEDs in parallel and solder two wires, the positive one connected to Arduino pin A3 and the negative connected to Arduino gnd. Fix it in place using hot gule.

Step 12: Connect the Back Lights

This is also a repetition from the previous version. Adding only front lights, makes the robot look incomplete so two red LEDs were connected at the back that look quite beautiful when glowing at night.

Connect two red LEDs in parallel then connect the positive terminal to Arduino pin A4. Finally connect the negative terminal to Arduino gnd. Stick it in place using hot glue.

Step 13: Connect the Neon Lights

Neon lights always look cool on cars when they glow on light. This was a try to add blue LED lights that would act as neon lights and increase the looks of the robot. They just look plain awesome when switched on at night. It makes the floor glow as well which looks wonderful.

As done in the previous two steps, connect them in parallel as well. Connect the positive terminal to Arduino pin D13 and negative to Arduino gnd. Finally fix them in place using hot glue as shown in the picture above. Make sure the light falls on the base on which the robot would move.

Step 14: Connect the Horn

What if you are controlling the robot and if someone comes on your way? In this case a horn can be quite useful. A simple piezo buzzer is used here so the horn is not as loud as a car horn. This can also be used to attract people's attention towards the robot or to irritate someone who is sleeping :D.

Connect the positive terminal of buzzer to Arduino pin D12 and negative to Arduino gnd. Stick it in place using hot glue below the place which will make the sound less loud.

Step 15: Connect the Ultrasonic Sensor

An ultrasonic sensor is added here to tell how far an obstacle is present. Distance is displayed on LCD as well as on laptop in centimeters when commanded to do so. The maximum distance that it can measure is around 400cm. The distance is not very exact but an approximate value. Connect it according to the following.

  1. Vcc ---- Arduino 5v
  2. Gnd ---- Arduino gnd
  3. Trigger ---- Arduino pin A2
  4. Echo ---- Arduino pin A1

Step 16: Connect the Battery Pack

The power supply used here is a battery pack that is made using two lead-acid batteries each rated at 4v, 1.0 Ah connected in series. This means that the battery pack will give 8v, 1.0 Ah which is enough to power an arduino. The battery is re-chargeable, cheap and light so can be a good option for the project. The battery also lasts long and can be charged easily. However you can use other type of batteries as well like AA's, Lithium and Alkaline.

Connect the positive terminal of battery pack to Arduino Vin pin with a switch in series and negative to Arduino gnd.

Step 17: Putting Everything Up

To prevent wires wires from breaking and the circuit not working, secure the wires using hot glue and stick them on the base. Add some hot glue in places where wires are soldered to prevent them from breaking like the terminals of motors. Also stick the ultrasonic sensor on the front part of the base.

Step 18: Add a Clamp for Your Phone

This step is optional and is only for those who want to add a camera to the robot. This is a great feature and really helps in controlling the robot without looking at it. Thus, the robot can also be used as a spy robot. You can also use a camera module which is smaller but makes the project a little complicated. So adding a phone is better than adding a camera module. Your phone can be connected to a laptop using a software so you can operate your phone through it. This allows you to operate your camera so you can look through the camera, take photos or make a video.

Make a clamp for your phone according to the dimensions of the phone. Make sure the phone is a little elevated allowing some space for ultrasonic sensor. Your phone should be tilted above so the image is not formed of the ground but of the surroundings. You can use any material to make the clamp. Add some foam to the clamp to prevent scratches coming on the screen.

Step 19: Upload the Code

Copy the code given below and paste it to your arduino ide screen. You need to remove the BT module before uploading as the rx and tx pins are associated with programming the chip so nothing should be connected to these pin while uploading the code. So either remove your arduino from the shield and upload the code or remove the BT module from its socket.

#include  // add your new ping library here
#include  // add your liquid crystal library here
LiquidCrystal lcd(11, 8, 7, 4, 3, 2);
float temp =1;
int temppin = A0;
int r_motor_n = 9; //PWM control Right Motor +
int r_motor_p = 10; //PWM control Right Motor -
int l_motor_p = 6; //PWM control Left Motor -
int l_motor_n = 5; //PWM control Left Motor +
int f_light = A3;
int b_light = A4;
int horn = 12;
int n_light = 13;
int speedy = 255;
int incomingByte = 0; // for incoming serial data
#define TRIGGER A2 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO A1 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER, ECHO, MAX); // NewPing setup of pins and maximum distance.
void setup()
{
pinMode(r_motor_n, OUTPUT); //Set control pins to be outputs
pinMode(r_motor_p, OUTPUT);
pinMode(l_motor_p, OUTPUT);
pinMode(l_motor_n, OUTPUT);
pinMode(f_light, OUTPUT);
pinMode(b_light, OUTPUT);
pinMode(n_light, OUTPUT);
pinMode(horn, OUTPUT);
digitalWrite(r_motor_n, LOW); //set both motors off for start-up
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
digitalWrite(l_motor_n, LOW);
Serial.begin(9600);
Serial.println("Start");
lcd.begin(16,2);
lcd.clear();
lcd.print("     Hello      ");
lcd.setCursor(0,1);
lcd.print("   I'm Robot   ");
delay(3000);
}
void loop()
{</liquidcrystal.h></newping.h></p><p>if (Serial.available() > 0) 
{
incomingByte = Serial.read();
}</p><p>switch(incomingByte)
{</p><p>case 'S': // control to stop the robot
digitalWrite(r_motor_n, LOW); 
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
digitalWrite(l_motor_n, LOW);
Serial.println("Stop");
lcd.clear();
lcd.print("Stop");
incomingByte='*';
break;</p><p>case 'R': //control for right
analogWrite(r_motor_n, speedy); 
digitalWrite(r_motor_p, LOW);
analogWrite(l_motor_p, speedy);
digitalWrite(l_motor_n, LOW);
Serial.println("right");
lcd.clear();
lcd.print("Right");
incomingByte='*';
break;</p><p>case 'L': //control for left
digitalWrite(r_motor_n, LOW); 
analogWrite(r_motor_p, speedy);
digitalWrite(l_motor_p, LOW);
analogWrite(l_motor_n, speedy);
Serial.println("left");
lcd.clear();
lcd.print("Left");
incomingByte='*';
break;</p><p>case 'F': //control for forward
analogWrite(r_motor_n, speedy); 
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
analogWrite(l_motor_n, speedy);
Serial.println("forward");
lcd.clear();
lcd.print("Forward");
incomingByte='*';
break;</p><p>case 'B': //control for backward
digitalWrite(r_motor_n, LOW); 
analogWrite(r_motor_p, speedy);
analogWrite(l_motor_p, speedy);
digitalWrite(l_motor_n, LOW);
Serial.println("backwards");
lcd.clear();
lcd.print("Backward");
incomingByte='*';
break;</p><p>case 'f': //control for stop
digitalWrite(r_motor_n, LOW);
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
digitalWrite(l_motor_n, LOW);
Serial.println("Stop");
lcd.clear();
lcd.print("Stop");
incomingByte='*';
break;</p><p>case 'd': // control for right
analogWrite(r_motor_n, speedy); 
digitalWrite(r_motor_p, LOW);
analogWrite(l_motor_p, speedy);
digitalWrite(l_motor_n, LOW);
Serial.println("right");
lcd.clear();
lcd.print("Right");
incomingByte='*';
break;</p><p>case 'a': // control for left
digitalWrite(r_motor_n, LOW); 
analogWrite(r_motor_p, speedy);
digitalWrite(l_motor_p, LOW);
analogWrite(l_motor_n, speedy);
Serial.println("left");
lcd.clear();
lcd.print("Left");
incomingByte='*';
break;</p><p>case 'w': // control for forward
analogWrite(r_motor_n, speedy); 
digitalWrite(r_motor_p, LOW);
digitalWrite(l_motor_p, LOW);
analogWrite(l_motor_n, speedy);
Serial.println("forward");
lcd.clear();
lcd.print("Forward");
incomingByte='*';
break;</p><p>case 's': // control for backward
digitalWrite(r_motor_n, LOW); 
analogWrite(r_motor_p, speedy);
analogWrite(l_motor_p, speedy);
digitalWrite(l_motor_n, LOW);
Serial.println("backwards");
lcd.clear();
lcd.print("Backward");
incomingByte='*';
break;</p><p>case 'J': // front lights on
digitalWrite(f_light, HIGH);
Serial.println("front lights on");
incomingByte='*';
break;</p><p>case 'j':
digitalWrite(f_light, LOW); // off
Serial.println("front lights off");
incomingByte='*';
break;</p><p>case 'K':
digitalWrite(b_light, HIGH); // back lights on
Serial.println("back lights on");
incomingByte='*';
break;</p><p>case 'k':
digitalWrite(b_light, LOW); // off
Serial.println("back lights off");
incomingByte='*';
break;</p><p>case 'G':
digitalWrite(n_light, HIGH); // neon lights on
Serial.println("neon lights on");
incomingByte='*';
break;</p><p>case 'g':
digitalWrite(n_light, LOW); off
Serial.println("neon lights off");
incomingByte='*';
break;</p><p>case 'H':
digitalWrite(horn, HIGH); // horn on
Serial.println("horn on");
incomingByte='*';
break;</p><p>case 'h':
digitalWrite(horn, LOW); off
Serial.println("horn off");
incomingByte='*';
break;</p><p>case 'O': // PWM speed values
speedy = 0 ;
Serial.println("speed= 0");
lcd.clear();
lcd.print("Speed=0");
incomingByte='*';
break;</p><p>case '1':
speedy = 155;
Serial.println("speed= 10");
lcd.clear();
lcd.print("Speed=10");
incomingByte='*';
break;</p><p>case '2':
speedy = 165;
Serial.println("speed= 20");
lcd.clear();
lcd.print("Speed=20");
incomingByte='*';
break;</p><p>case '3':
speedy = 175;
Serial.println("speed= 30");
lcd.clear();
lcd.print("Speed =30");
incomingByte='*';
break;</p><p>case '4':
speedy = 185;
Serial.println("speed= 40");
lcd.clear();
lcd.print("Speed=40");
incomingByte='*';
break;</p><p>case '5':
speedy = 195;
Serial.println("speed= 50");
lcd.clear();
lcd.print("Speed=50");
incomingByte='*';
break;</p><p>case '6':
speedy = 205;
Serial.println("speed= 60");
lcd.clear();
lcd.print("Speed=60");
incomingByte='*';
break;</p><p>case '7':
speedy = 215;
Serial.println("speed= 70");
lcd.clear();
lcd.print("Speed=70");
incomingByte='*';
break;</p><p>case '8':
speedy = 225;
Serial.println("speed= 80");
lcd.clear();
lcd.print("Speed=80");
incomingByte='*';
break;</p><p>case '9':
speedy = 235;
Serial.println("speed= 90");
lcd.clear();
lcd.print("Speed=90");
incomingByte='*';
break;</p><p>case 'q':
speedy = 255;
Serial.println("speed= 100");
lcd.clear();
lcd.print("Speed=100");
incomingByte='*';
break;</p><p>case 'p': 
delay(50);  // display temp. and distance
unsigned int uS = sonar.ping(); 
Serial.print("Distance: ");
Serial.print(uS / US_ROUNDTRIP_CM); 
Serial.println("cm");
lcd.clear();
lcd.print("Distance: ");
lcd.print(uS / US_ROUNDTRIP_CM); 
lcd.print("cm");
lcd.setCursor(0,1);
temp = analogRead(temppin);
temp = temp * 0.48828125;
Serial.print("Temperature = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
lcd.print("Temp. = ");
lcd.print(temp);
lcd.print("*C");
delay(1000);
incomingByte='*';
break;</p><p>delay(5000);
}
}</p>

Step 20: Install Teraterm and Connect

After completing everything, connect all the parts to their respective sockets and make sure you connect them in the correct way. Now, it's time to connect the robot to the laptop.

Like the previous robot, this one is also uses teraterm to control it. I recently found that it can also be controlled using arduino ide but I would recommend teraterm rather than ide. Follow these simple steps to connect your robot and control it.

Teraterm:

  1. Switch on your robot so the bluetooth module is activated.
  2. Go to devices and printers on your laptop (windows).
  3. Select add a device.
  4. On searching for devices, it would find one named HC-05, HC-06 or any other name.
  5. Select your module and enter the pairing code as 1234. The device driver would be installed.
  6. Select your module and check the serial port in properties. (eg. com45, 64 etc.)
  7. Open teraterm. A connection screen would appear. Click on serial.
  8. Now select your device's com port and click ok. It would be connected to your robot.

Arduino IDE:

  1. Repeat steps 1 to 6 mentioned above.
  2. Open arduino ide and change the serial port to your bluetooth module's port. (not your arduino's port)
  3. Now open serial monitor. It would be connected to your robot.
  4. Make sure the baud rate is set at 9600. To send commands, type it on the screen above and select send.

Step 21: Check the Robot

After connecting your robot, you need to check it whether you did it right or not. For this send the commands one by one given below. If one of the features is not working, check all the connections and retry. If the robot is moving left or right when the forward button is pressed, keep adjusting the polarity of the motors until they move correctly. For the LCD keep turning the preset unless something is displayed on the screen. The commands for controlling the robot are-

  1. Forward - w
  2. Backward - s
  3. Left - a
  4. Right - d
  5. Front lights on - J
  6. Front lights off - j
  7. Back lights on - K
  8. Back lights off - k
  9. Neon lights on - G
  10. Neon lights off - g
  11. Horn on - H
  12. Horn off - h
  13. Display distance and temperature - p
  14. Speed 0 to 90 - 1 to 9 (eg. speed 40 - 4)
  15. Speed 100 - q

Step 22: Install Airdroid (Optional)

Airdroid is a software used to connect your mobile to a pc or a laptop. Here it is used to connect the phone camera to the laptop. For this you need to install airdroid both on your laptop as well as your phone. Visit the official airdroid website to download the app for both. You can connect your phone online as well as offline. For connecting follow these steps-

  1. Open airdroid on your phone. Go to tools or settings and enable Tethering and wifi Hotspot.
  2. Now connect to a device named airdriod ap on your laptop through the wifi. Select accept on your phone.
  3. Open a browser. (not airdroid sofware) Make sure you are not connected to internet on both phone as well as laptop.
  4. A link would be displayed on your phone's airdroid consisting of some numbers. Type the same link to the browser.
  5. Your phone would now be connected to the laptop. Select camera and your phone's camera would open.
  6. Set your phone on the robot's clamp. The image quality would depend upon the quality of your phone camera.

Step 23: Control Using an Android Device

One of the best of list the of features of this robot is that it can also be controlled using an android device. For this you need to download an application named 'Bluetooth serial controller' that can be the best to control this type of robot. Another app can be 'Bluetooth RC controller' but the problem with this app is that you can only control the movements as the commands sent by it differ from the commands written in the code.

After downloading the app, you need to set the buttons according to the commands of the robot which is not a difficult task at all. Just change the name and the command of the button. For movement controls, set the stop command to 'S' that will stop the robot when the button is released. You can make a total of 6 controllers each with 16 buttons.

Step 24: You're Done!

So, you have made your own laptop controlled robot. Enjoy moving it around your house or your backyard with a range upto 15m. But that't not it. You could even make it better by adding more commands and features to it. You just need to have some little knowledge in arduino programming. You could even add a wireless camera instead of using a phone which would save space. If you are a beginner and want to make a simpler one, switch to my Laptop controlled robot v1.0.

That's the end of the instructable. Hope you liked it. Do post your pictures if you've made it and tell me if you've added something new. Feel free to comment or ask any questions. Please vote for me if you think this deserves a win. THANK YOU:)