How to Build a Basic Arduino Robot




Introduction: How to Build a Basic Arduino Robot

This ‘how to build a robot’ series gives you the complete step-by-step tutorials which aims to help robotic beginners to make their own robot that based on Arduino. The tutorial goes through the basic knowledge of a robot (how to use the tools, how to assemble your own robot, how to program and how to make your robot move) to more advanced functions (obstacle avoidance, line tracking, lighting and sound effect, environmental monitoring, Bluetooth Control). The tutorial is filled with tons of pictures and diagrams so that anyone can build their own Arduino robot without any difficulty!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: ​Lessons Menu:

Lesson 1: Introduction

Lesson 2: Build a Basic Arduino Robot

Lesson 3: Build a Line Tracking Arduino Robot

Lesson 4: Build an Arduino Robot That Could Avoid Obstacles

Lesson 5: Build an Arduino Robot With Light And Sound Effects

Lesson 6: Build an Arduino Robot That Could Monitor Environment

Lesson 7: Build a Bluetooth-Controlled Arduino Robot

Step 2:

Generally speaking, a robot is virtual artificial or mechanical agent that is able to react to its environment and autonomously decide actions to achieve the particular goal. These characters distinct robots from things like cars or toaster as they could not perceive their environment.

Robot is usually controlled by an electronic circuitry or computer program. Here I made a picture indicating the basic composition of an Arduino robot.

The robotic platform is the body of a robot that decide it will look like and what it will do. Wheeled platform is currently the most common one. Compared with others, it has several advantages such as the relatively low-cost, abundance of choice as well as the simple design and construction. It is highly suggested for robotic beginners.

A microcontroller is the brain of a robot as it is able to execute a program and therefore in charge of all decision making, computation as well as communications. The Arduino UNO and Romeo are two popular microcontrollers for DIY Arduino robot.

Motors are devices that could convert electrical energy into physical motion while motor drivers act as the intermediate device between a microcontroller, a battery and motors. It provide the current at the required voltage and work together with microcontrollers to make the motors move appropriately.

Robots have the capability to perceive surroundings thanks to various electromechanical sensors. For example, an infrared sensor could help an Arduino robot to detect the distance between itself and an object and then fed back this information to the microcontroller; a grayscale sensor is needed to make a line-tracking robot.

Before we start making a robot, it would be better to know some essential tools.

Step 3: Essential Tools


Screwdriver, a tool for turning screws (driving or removing) is indispensable for building a robot. We suggest that you get yourself a screwdriver set, which is extremely convenient in dealing with screws of different types and sizes.

Sodering Pencil

A soldering pencil is a tool frequently used in electronics projects for soldering and de-soldering work on circuit boards. We’ll need it in this project to solder the motors’ cables.

NOTE: Once heated, the tip of the soldering pencil will become extremely hot. If you have never used a soldering pencil before, please spend some time familiarizing yourself with how to use the pencil. BE CAREFUL when using the soldering pencil!

Needle-nose plierse

Needle-nose plierse are often used to cut off excess length from cables and wires. We won’t be using the pliers much for this project; however, they’re an essential tool in electronics projects.

Wire Stripper

A wire stripper is a hand-held tool used to strip the electrical insulation off of wires. The wire stripper can also be replaced with scissors if needed. When using this tool, only the first layer of insulation needs to be stripped, exposing the lead wire inside. This helps make the soldering process easier.

Step 4: Assembly Instructions - Step 1

Next, you will be taught to build a basic Arduino robot. To make this tutorial easy to follow, an Arduino robot kit (Pirate: 4WD Arduino Mobile Robot Kit with Bluetooth 4.0) is used here as an example.

STEP1: Assemble Your Own Motor

Look in your parts bag for eight long screws. These are used to fix and secure the motors in place. Place the motors in the correct alignment, then screw them into place as shown in the picture below.

Please note that washers and gaskets are also included in the parts bag. Washers can be used to increase friction, which helps fasten the motors into place. The gaskets help prevent the screw nuts from loosening and falling off due to your robot ’s movements and collisions.

Step 5: Assembly Instructions - Step 2:Soldering the Cables

Take the black and red wires out of the parts bag. Attach one black and one red cable (15 cm long) to each motor (4 motors in total). Then use your wire stripper to strip the insulation at both ends of the wires (make sure not to strip too much—refer to the pictures below). Next, solder the wires onto the pins affixed to the motors. Repeat the soldering process for all four motors.

NOTE: Pay attention to the correct locations of the red and black wires when soldering. Please consult the following photos for details.

Step 6: Assembly Instructions - Step 3: Assemble the Romeo BLE Controller

Look in your parts bag for three copper supports. Those 1cm-long supports are used to fasten the Romeo controller board. As shown in the picture below, there are three holes in the controller board. Place the three copper supports into the holes, then fasten them into place with the appropriate screws.

Step 7: Assembly Instructions - Step 4: Assemble the Romeo BLE Controller

Take out two countersunk screws (their heads are flat). Then follow the steps shown in the picture below and affix the battery to the car base.

Step 8: Assembly Instructions - STEP5: Crafting the Power Switch

Batteries are the essential lifeblood of robots. To control power usage, we need to use a power switch: the switch turns off power when not in use, thus preserving electricity and battery life. Refer to the picture below before assembling and installing the power switch.

Please pay attention to the sequence of the gaskets and screw nuts when assembling the switch.

After assembling the switch, we want to start soldering its wires. Take some of the remaining wire leftover from before. Strip the wiring off both ends of the cables so that the inside of the wire is exposed (same process as with the motors before). We want to solder the exposed end of the wires to the pins on the switch. When soldering, it’s very important that we note the position of the switch’s pins.

Let’s do this step by step.
a)Connect the switch to the battery charger. Pay attention to the exact location of both items.

b)Solder the red cables connecting the switch with the battery charger as shown in the picture below.

c)Finally, take one red cable and one black cable. Attach one end of one cable to the negative pole of the battery charger and one end of the other cable to the positive pole of the battery charger. Then attach the other ends of both cables to the Romeo BLE controller.

Looking at this enlarged picture should give you a better idea of how the wires should be connected. After soldering, make sure to check and see if your wiring between the battery and Romeo controller is consistent from start to finish and matches with the above pictures.

Step 9: Assembly Instructions - STEP6: Crafting the Power Switch

Using eight M3x6mm screws, attach the side plates to the front and back bumper plates as shown by the diagram below.

NOTE: When tightening the screws during this step, make sure not to fully tighten the screws at first — this way, we can easily detach the top board in later steps should we need to make adjustments.

Then, re-attach the base plate to the body of the car.

** This is what the car base should like after it’s been assembled — remember to install the battery pack!

Step 10: Assembly Instructions - STEP7: Connect the Motors With the Microcontroller Board

Now we need to the motors with the microcontroller board. Carefully follow the following diagram: the left motor’s red and black wires should be soldered into M2; the right motor’s red and black wires should be soldered to M1. Pay special attention to the battery pack: the black wire should be soldered into the wire port reading GND, while the red wire should be soldered in the wire port labeled VND. Use your screwdriver to loosen and tighten the wire ports — make sure these ports are fastened well once the wires have been inserted.

NOTE: Make sure the wires from one motor (i.e. the left motor) are soldered into the motor port. (i.e. the M2 port on the diagram below — do not solder one motor’s wires into two separate ports.)

After soldering the motor wires to the microcontroller board, we’re ready to attach the top plate to the base of the car.

Before we attach the top plate, you have the option of attaching a sensor plate (see diagram below) — if you don’t plan to use sensors just yet, you can skip this extra step.

After attaching the top of the platfrom, your robotic platform should resemble the picture below.

Step 11: Assembly Instructions - STEP8: Attach an Extra Level to Your Robot

Find the four holes on the base’s top plate. Screw in the four M3x60mm Copper Standoffs, then attach the additional top plate as shown in the diagram below — use M3x6mm screws to affix the plate to the copper standoffs.

Toss some wheels on your robotic platform and you’re ready to let it whip!

Step 12: CODING

After assembling, it’s time to upload code onto the microcontroller and make your Arduino robot move. The robot has all the components for moving once assembled. Look through the sample codes for the Arduino file titled “MotorTest.ino”.

Sample code MotorTest:

DFMobile Robot (4,5,7,6); // initiate the Motor pin

void setup () { Robot.Direction (LOW,HIGH); // initiate the positive direction }

void loop () { Robot.Speed (255,255); //Forward delay (1000);

Robot.Speed (-255,-255); //Back delay (2000); }

Download the code, then upload it to your microcontroller. The motors and wheels should come alive in a hurry. If not, check to see if your batteries and power switch are properly installed. Once the motors are working, congrats! You’ve completed a big step — it’s almost time to put our rubber to the road.

Then observe your robot car and check if it may move forward within 1 second and move back within 1 second. If that’s the case, GOOD LUCK. You don’t have to adjust the components. For those who need to make some adjustments to the car base or motors, please find the following information about how the robot moves.

Check to see if your robotic platfrom follows the code shown above: it should move forward for 1 second, then reverse for 1 second. If that’s the case, just skim the content below and then you’re ready to go!

Most people, however, will need to make adjustments to their motors. Before we do that, let’s briefly review how our robot’s motor function and code works.

Step 13: How to Make the Robot Move Forward?

In order to understand this question, let’s first examine our robot’s forward movement.

The diagram below illustrates this forward movement.

The red arrow above represents the direction of the wheels. As it is shown in the map above, the car can move forward only if both the left and right wheels/motors are moving forward. As shown above, the Arduino robot only moves forward when both the left and right motors and wheels are moving forward.

Code Synopsis

The first line of code is:

#include // call library

We don’t need to think too much about this line. All we’re doing is calling upon/employing a set of functions — the DFMobile library — that exist outside of Arduino’s basic framework. For more information on Arduino libraries, please check out the Arduino website.

The next line of code is:

DFMobile Robot (4,5,7,6); // initiate the Motor pin

This function is taken from the DFMobile library (that is, it’s not a universal Arduino function). We use it here to initialize the motor pins (4, 5, 7, 6) on the microcontroller — without this, the motors won’t start.

We’ll be using this function later on as well.

Take a look at the function below:

DFMobile Robot (EnLeftPin,LeftSpeedPin,EnRightPin,RightSpeedPin);

This function is used to initialize the four motor pins (4, 5, 7, 6) and is divided into four separate parameters:

EnLeftPin: Pin that controls left motor direction

LeftSpeedPin:Pin that controls left motor speed

EnRightPin:Pin that controls right motor direction

RightSpeedPin:Pin that controls right motor speed

Please note: the robot’s motors won’t run without the inclusion of this function. Also, this function must be placed within the void setup() field in your Arduino sketch.

In testing your robot’s forward motion before, we might’ve encountered a certain problem: the car will start to drift, change directions and not quite follow the code we’ve given it. This is due to the motor wires not being soldered to the batteries in the correct manner.

Don’t worry — we can correct this through code. By using LOW/HIGH values, we can adjust the direction of the car’s turns.

Step 14: How to Adjust the Straight Direction for the Robot Car?

To adjust the direction of the motors and wheels, we need the following line of code:

Robot.Direction (LOW,HIGH);

The function is as follows:

Robot.Direction (LeftDirection, RightDirection);

This function is used to make the motors move in a forward direction. The function is divided into two parameters: LeftDirection & RightDirection, which are written in the Arduino code as either LOW or HIGH.

Earlier, we briefly went over how to make the Arduino robot move in a forward direction. Here, we’ll use LOW/HIGH to correct the robot’s wayward movement. For instance, LeftDirection is set as LOW in the sample code. But left wheels of the robot car may rotate backwards instead of rotating forward. Now all you have to do is to change the LeftDirection from LOW to HIGH. The same methods would apply to the right wheels. For example: in this sample code, LeftDirection is configured as LOW. Suppose your left wheels, rather than moving forward as they should, instead move backwards. In this case, change the configuration of LeftDirection from LOW to HIGH. Once you change it to HIGH, upload your code once more — you should notice that your left wheel is moving forward now instead of backwards. If this adjustment works, do the same for RightDirection (LOW to HIGH or vice versa).

Once you’ve successfully adjusted your Arduino robot’s direction, you’re set! Congratulations — you can now use all of the robot’s basic functions. Before finishing up, though, it’s worth it to briefly discuss the Robot.Speed() function.

Take a gander at the following function:

Robot.Speed (LeftSpeed,RightSpeed);

This function with two elements (LeftSpeed and RightSpeed) is used to set the speed of the motor. You may write a number between -255 and 255. 255 is the maximum figure and the minus sign represents the direction.

This function is used to configure the speed of the motors. The function is divided into two parameters: LeftSpeed & RightSpeed. These parameters are written in Arduino code as a value ranging from -255 to 255. 255 is the fastest velocity moving forward; -255 is the fastest velocity moving backwards (that is, reversing).

We already configured the robot’s speed in the void setup() part of our code. Now, we can use the speed() function to control the car’s speed and even forward/backwards direction.

See if you can understand the following two lines: Robot.Speed (255,255); Robot.Speed (-255,-255);

The first line shows the car moving forward at full velocity — full speed ahead, if you will (aye aye, captain). The second line shows the car moving backwards (reversing) at full velocity.

In this sense, speed() is an indispensable function. Next, we’ll review our last section: the principles behind how the robot moves and turns.

Step 15: How the Robot Moves and Turns

The map below shows some regular way of movements for the robot car. For example, in case that speed of the Left Direction is zero, the robot would turn left if you offer the right wheels some force to move forward.

The following diagram displays a number of ways in which the Arduino robot can move and turn. For instance, if the speed of the left wheels is set to 0, that will cause the right wheels to move forward — thus, the Arduino robot would turn towards the left.

Something to consider: how can we make your robot rotate in circles while stationary?

Lastly: if you want, you can run some more code to test and calibrate your own robot’s movement. Open the “MotorTest2.ino” file. This code should help you better understand and gauge the capabilities of forwards and backwards movement, in addition to left and rightturns. With this in mind, put those tires to the road (or carpet) and let’er rip!

Congratulations, now you have built your first robot! It has bacis functions that could move forwward,backward, turn left and turn right.

Feeling excited? In next few tutorials, we will teach you how to build a more advanced robot that could avoid obstacles and track line for instance.

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge



    Question 1 year ago

    Why are some images just black?