In this tutorial we will discuss a simple PC controlled robot. The Robot PC link will be a RS232 serial line. The robot will have only five commands.

  1. Move forward (RS232 char ‘F’ or ‘f’)
  2. Move backward (RS232 char ‘B’ or ‘b’)
  3. Turn Left (RS232 char ‘L’ or ‘l’)
  4. Turn Right (RS232 char ‘R’ or ‘r’)
  5. Stop (RS232 char ‘S’ or ‘s’)

To keep things as simple as possible, in this example we will use terminal software RealTerm for sending commands to the robot. Later on a dedicated software can be written on PC end to control the robot.

The Robot’s Hardware

The robot’s hardware will be a simple differential drive using two 200RPM DC Gear motor mounted on a HQ Metal Chassis with a front castor wheel. On the back motors we have mounted plastic wheels. More about differential drive is explained in this tutorial.

gear motors

Gear Motors





metal chassis

Metal Chassis


remove motors nut

Remove motor’s nut


insert the motor

Insert the motor


fasten the nut again

Fasten the nuts again


both motors installed

Both motors installed


the front castor

Front Castor wheel


installing the front castor

Installing the front castor


mounting hole for wheels screew

Mounting hole for wheels screw


Mounting the wheels

Mounting the wheels


robots chassis is ready

Chassis is ready!

The Electronics

The robot is controlled using xBoard v2.0 which has ATmega32 as main CPU and integrated motor drivers. We have connected xBoard v2.0 with PC using a CP2102 USB to UART module.

xBoard robot controller

xBoard v2.0


xboard back view

Mounting Screws


xBoard mounted

xBoard v2.0 mounted on chassis


motor connection

Motor connectors

Connect right motor to MOTOR-A Connector and left motor to MOTOR-B.

motor connection

Motors connected


fasten the motor wires

Fasten the screws


pc controlled robot

Neat ! Isn’t it ?

Download and Burn the Firmware HEX file

Download the firmware hex file from the link given below and program it to the xBoard v2.0 using a USB AVR Programmer. Make sure the fuse bits are set as follows :-

HIGH Fuse = 0xC9

LOW Fuse =0xFF

Setting AVR Fuse Byte

Fig.: Setting the Fuse bytes.

CP2102 Module Connection

cp2102 module

CP2102 Module (USB to TTL)


xBoards UART pins

Neat ! Isn’t it ?

Connect one side of CP2102 module to USB and other side to xBoard v2.0 as listed below.

xBoard v2.0 CP2102 Module

other pins of CP2102 are unused.


  • Make sure that CP2102 drivers are installed.
  • Jumper JP4 is in Off position (non white side)
  • Jumper JP2 and JP3 are in On position (white side)

Finding the COM port number of CP2102 module.

A PC can have several COM ports, each may have some peripheral connected to it like a Modem. Serial Ports on PC are numbered like COM1, COM2 … COMn etc. You first need to figure out in which COM port you have connected the AVR. Only after you have a correct COM port number you can communicate with the AVR using tools such as Hyperterminal. The steps below shows how to get COM port number in case of Virtual COM Ports.

Right Click on "My Computer" icon in Windows Desktop.

my computer icon

My Computer Icon on Windows Desktop

Select "Properties"

right click on my computer

System Context Menu

The System Properties will open up. Go to the "Hardware" Tab.

System Properties.

In Hardware tab select "Device Manager" button. It will open up device manager.

Open Device Manager

In Device Manager Find the Node "Ports (COM & LPT)"

Expand the PORT node in Device Manager

Depending on whether you are using a "USB to Serial Converter" or "CP2102 USB/USART Bridge Module" you have to find the port with following name.

Note down the COM port number next to the port name. You need to open this Port in Hyperterminal.

com port number

COM Port Number


com port number

COM Port Number

Setting Up Real Term

If you are running Windows Vista or Windows 7 then the Hyperterminal Program may not be available. So in place of it you can use Realterm. It can be downloaded from here.

Start Realterm from its Desktop Icon. You will get a screen similar to this.

realterm setup

Real term setup

Go to the "Port" tab and make settings as shown above. Port number is the COM Port number of CP2102 you have found above.


  • Baud is set to 19200
  • "Open" button is in depressed state.

Now turn on the xBoard v2.0, you will see the following message pops on the terminal.

realterm robot message

Greeting message from robot

Sending command to your robot.

sending command to robot using realterm

Sending commands

  1. Go to the "Send" tab
  2. Enter the command Eg. ‘F’ without the quotes.
  3. Click "Send ASCII" button.

If every thing goes well the robot will respond with message "Forward" (or any other command you gave like "Turn Right") which will be shown on the terminal screen.

Command Acknowledge from Robot

Sending commands

In the same time the robot will start moving forward.

Source Code (Members Only)

PC Operated Robot Source (2736)


Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

More Posts - Website

Follow Me:
FacebookLinkedInGoogle Plus