loading

In this Instructable I will show you how to build a robot that is controlled via Bluetooth using a keyboard, has a graphical user interface built with processing that displays the input from the keyboard and actually turns the whole bushiness into a great fun, and It's also economical to build. I've also made a video about it and uploaded it to YouTube. I recommend you to check out the video in order to better understand the process of this build. We will use 3 programs: The Arduino IDE (Which is based on C# and C++), Processing (Which is based on Java) and Toshiba Bluetooth stack (That will allow us to work with the Bluetooth module). I will leave links for everything you need, including software. The operating system of my computer is Windows 7, but any Windows version would be just fine. All the code will be outlined, So keep confident.

To Sum, This Instructable will describe how to build a physical robot, program it, control it remotely and even build a friendly user interface for it.

*Check the beginning of the video for a demo !

Step 1: Hardware- a Chassis !

The first step of this build is to obtain a chassis. The chassis has to include a body and two servo motors. It can be either bought online, taken out of an old RC car or made in home using common materials such as cardboard, exactly like in this robot. I've made the body using a cardboard rectangle (12CM ^ 16CM) and then cut 2 circles, attached them to the two servos using hot glue and screws to act as wheels, attached the servos to the chassis using Double sided tape and finally applied a thin layer of hot glue to the wheels to act as tires and to improve grip. I've also attached a bottle cap to the rear bottom of the robot in order to reduce friction with the floor.

For convenience, I've added links for multiple sites:

Chassis (Note that if you buy a chassis online then it will be probably based on DC motors, And so you will have to use a motor shield and modify the Arduino code as well) -

Ebay US: http://goo.gl/LbWVTj

Ebay UK: http://goo.gl/haaxl0

Amazon: http://goo.gl/VGOsc7

Aliexpress: http://goo.gl/mjY6et

DealXtreme: http://goo.gl/1vL9qV

Continuous rotation servos-

Ebay US: http://goo.gl/Nqb5Lk

Ebay UK : http://goo.gl/EkYktu

Amazon: http://goo.gl/2EOkp0

Aliexpress: http://goo.gl/Nqb5LkEbay

Step 2: Arduino + Bluetooth Module

You will also need an Arduino board and a Bluetooth module. I'm using the Arduion Uno and the HC-06 module, and I'll leave a link for where you can get it online. A Bluetooth usb adapter will be needed as well in case your computer doesn't have a Bluetooth built-in.

Start by attaching the Arduino board to the body of the chassis. To achieve that, I've used a small amount of double sided tape in a spot without solder joints.

By now you should have an idea of how this robot is going to look like.

Links:

Arduino Uno-
Ebay US: Arduino Uno Ebay

Ebay UK: Arduino Uno Ebay UK

Amazon: Arduino Uno Amazon

Aliexpress: Arduino Uno Aliexpress

Bluetooth Module (HC-06)-
Ebay US: http://www.ebay.com/itm/Wireless-Serial-4-Pin-Blu...

Ebay UK: http://www.ebay.co.uk/itm/Wireless-Serial-4-Pin-Bluetooth-RF-Transceiver-Module-HC-06-for-Arduino-30ft-/361149533231?pt=LH_DefaultDomain_3&hash=item5416308c2f

Amazon: http://www.amazon.com/JBtek-Bluetooth-Converter-S...

Aliexpress: http://www.aliexpress.com/item/1pcs-HC-06-HC06-JY...

Step 3: Power !

This part is quite simple, since I'll simply specify which batteries I Have used.

I've used a 2 cell 1200 Mah lithium battery for the servos, and a 5V 1000 Mah back-up battery for the Arduino itself. You can also use a 9V battery to power the Arduino, and 4 AA batteries to power the servos. Anyway, You'll see how everything works out in just a second.

Again, Attach both of them to the Arduino using a small amount of double sided tape.

Links:

Power Bank Battery for the Arduino-
Power Bank Ebay

2S 1200 Mah lithium battery for the servos-

Lithium Battery Ebay

2S battery charger-

Lithium Battery Charger

Step 4: Connecting Everything Together

For easier wiring, I recommend using a Prototyping shield. The bluetooth module has 4 pins: Voltage (VCC), Ground (GND), Transmit (TXD) and Recieve (RXD). Start by connecting it to the Arduino according to the diagram above. The resistors are used to act as a voltage divider, so make sure you do not forget them, since the Transmit and Receive pins of the Bluetooth module operate on 3V and cannot handle the 5V current of the Arduino. Finally, connect the Servos to the Board according to the second diagram.

Links:

Prototyping Shield-
Ebay US: Prototyping Shield Ebay US

Ebay UK:Prototyping Shield Ebay UK

Amazon: Prototyping shield Amazon

Aliexpress:Prototyping Shield Aliexpress

Step 5: Code- Theory

Let's speak theoretically. We have a robot, and we would like to control it remotely with a keyboard using Bluetooth and have a nice user interface that would allow us to do this easily. In order to do that, we will need a computer and a software called Processing. Processing is an open source visual programming language that will allow us to receive input from the keyboard, display it on our interface and send signals through the Bluetooth serial port. We will then upload a program to the robot using the Arduino IDE that will listen for the signals in the Bluetooth serial port, and take different actions according to which signal arrived. For example, If the UP button on the keyboard is pressed, the processing software receives it as an input, displays it on the screen and sends the number "1". The robot, which lays within the Bluetooth range, receives the number "1" and moves forward, since it is defined in its code that the number "1" means forward. If the right button is pressed then the number "2" is sent and the robot moves right, if the space button is pressed the robot brakes and so on and so forth.

Using this method you can even add some really neat features, such as turning on LED headlights by pressing the "L" key.

Step 6: Arduino Code

We'll start by creating the Arduino code that will run on the robot, and listen for the signals in the serial port.

First, open the Arduino code. After You've opened it, Upload it to the board. Make sure that the Bluetooth module is disconnected while you are uploading the code, Otherwise you will get an error and It won't work. After the upload is complete, you can reconnect your Bluetooth module.

I've wanted to paste the code here, But unfortunately It scrambled the whole thing into a big mess of letters, so I've simply uploaded it as a file.

I've explained all of the code using grey comments, in order to allow everybody to understand it.

Step 7: Initializing the Connection With the Robot

First, Go ahead and download Toshiba Bluetooth Stack, That will allow us to turn the Bluetooth module into a Serial Port we can work with.

Choose a download link that suits your system:

Windows 7 64 bit

Windows XP/Vista/7 32 bit

If one of them doesn't work, Then try the other one.

Simply follow the pictures above and Their instruction notes.

Step 8: Creating the GUI (Graphical User Interface) for the Robot

The thing that sets aside this robot from others is the fact that it has a whole user interface built especially for him. To make it, I've used Processing. Using the graphical functions, I created and aligned squares and triangles to simulate a keyboard's arrows. The program receives input from the keyboard, and flashes the shapes according to which button was pressed (You can check the video at the beginning for demo). It then sends signals through the Bluetooth serial port accordingly (Remember, the ones that the Arduino listens for ?). This way we can control the robot remotely using a keyboard.

Controls:

Forward = UP arrow

Backwards = DOWN arrow

Right = RIGHT arrow

Left = Left arrow

don't forget that you can modify the code and add more cool features.

So without further redo, go to Processing.org and download processing. Afterwards, use it to open the RobotGuiV2.

This part is quite tricky. Whenever we run the program a list of the available ports appear in the output section. And indeed, Port 40 is available. But, whenever we enter the port 40 into the program, we get an error. Well the truth is that you have to check which port works for you. The one that worked for me is 11, And it will probably work for you as well, but if not, then simply play with your available ports, until you get it.

Again, I've clarified the entire code using grey comments.

Step 9: Done ! + About Me

After You've found the correct port, Your robot is done. Now you can control it remotely with your keyboard. enjoy !

I found it to be very fun. About the range, it really depends on your Bluetooth module. I had no problem driving in my room.

Feel free to examine, modify and play with the code. You can change the keyboard buttons, add more features, and maybe even improve the robot.

I hope this tutorial was helpful, I had a great time writing it. If this Instructable was indeed helpful, Please Vote ! I've entered two contests: Coded creations and Move It.

A few words about myself:

I'm a 15 year old guy called Roy, whose interests include, among others, robotics, electronics and programming. I intend to keep uploading videos like this to YouTube and writing this kind of Instructables. So, If you like these kind of things that I do, please subscribe ! It means a lot.

Yours,

Roy.

hey roy, this is lucky....i m trying to make the same project which you have made ....here i m facing a problem...that not a single attached file (such as .ino / .pde)is opening on my system...can you provide me all the codes and other files by another way<br>
<p>Excellent!! I'm also a teen working on a handful of arduino projects. I'm also interested in gardening, so I want to incorporate smart into gardening through arduino and raspberry pi. keep it up!</p>
<p>Hi, I'm fairly new to this, but i was wondering because I'm using DC motors I think that's what they're called whether I would need to define the DC motors not as servos since at the moment the code still defines servos, but I'm using DC motors &amp; I just wondered would I need to change the code within the arduino program? Hope I'm making sense aha &amp; hope you or anyone will be able to help :)</p>
<p>how to connect 4 servo motors to it ???</p>
May i know how u build that application software..for pc please tell me ..
<p>wah roy wah</p>
<p>Great work!!</p>
<p>Great Work!!</p>
<p>would anybody be able to help me in adding a camera into this</p>
<p>I can not paring CSR 4.0 to blutooth ZS-040. anybody can explain?</p>
How can i add a camera to this whole project plz help
<p>could you write me a code for controlling this car with a phone</p>
<p>Upload this sketch to your arduino board(remember to remove your bluetooth module)</p><p>#include &lt;Servo.h&gt; //Import the Servo library</p><p>Servo SERVO_1; // Initialize Servo1 </p><p>Servo SERVO_2;// Initialize Servo2</p><p>void setup() {</p><p> Serial.begin(9600); // Initialize Serial Communitication</p><p> pinMode (13,OUTPUT); // Optional for Led Headlights, Reverse Lights, Etc.</p><p> SERVO_1.attach(5); // Defining the servos' pins</p><p> SERVO_2.attach (6);</p><p>}</p><p>void loop() {</p><p>if (Serial.available() &gt; 0) //Listen for signal in the serial port</p><p>{</p><p>int data = Serial.read(); </p><p>switch (data) { // Switch-case of the signals in the serial port</p><p>case 'F': // Case Number 1 is received, </p><p>SERVO_1.write (180); //Go forward.</p><p>SERVO_2.write (0);</p><p>break;</p><p>case 'B' : //// Case Number 2 is received, </p><p> SERVO_1.write (0); // Go backwards.</p><p>SERVO_2.write (180);</p><p>break;</p><p>case 'R' : // Case Number 3 is received, </p><p> SERVO_1.write (180); // Turn right.</p><p>SERVO_2.write (180);</p><p>break;</p><p>case 'L' : // Case Number 4 is received, </p><p> SERVO_1.write (0); // Turn left.</p><p>SERVO_2.write (0);</p><p>break;</p><p>case 'S': // Case Number 5 is received, </p><p> SERVO_1.write (95); // Break.</p><p>SERVO_2.write (95);</p><p>default : break;</p><p>}</p><p>}</p><p>}</p><p>And then download this app</p><p><a href="https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller" rel="nofollow">https://play.google.com/store/apps/details?id=brau...</a></p>
<p>thanks a ton </p>
awesome
<p>Can u help me!pls...</p>
<p>if we use chasis instead of continuous rotational servos, how to install its components and modify code?</p>
<p>This is one of the coolest things I've ever seen. Thank you so much !</p>
<p>Incredible ! Thanks !</p>
very great !
<p>Thanks ! </p>

About This Instructable

14,172views

55favorites

License:

More by RoyPeer:PC Controlled Bluetooth Robot (With a GUI !) Obstacle Avoiding Robot  DIY fan powered boat 
Add instructable to: