Robot Motor control using Arduino

Learn how to make motor for Robots and how to control them using Arduino

One of the most important aspects of Robots design motor. Robots needs motors for motion and one must be able to control it’s speed and direction. Good electrical engineering school will teach you this, most do not.

This is continuation of the Arduino Projects for beginners. Here we show what hardware is required to control two motors, how to connect them, how you can use arduino shield to help you with learning. Specifically here you will learn how to turn on/off motor. In the next tutorial you will learn how to use potentiometer to control the speed of the motor.

The essential parts required in robotics with motor are DC motors, H-bridge, hex-inverters.

H-Bridge and Arduino Motor Shield

H-Bridge are electronics circuit which comes in IC that is used to apply voltage to DC motors in two direction. By applying voltages in two direction you can control the motor direction forward and backward. L298 is an example of H-bridge which is used here.

You can buy individual H-bridge IC but if you do so you need to create external circuit around the IC for motor control. For easier understanding and for easier building you can buy shields for L298 bridge which will be done here. Below is a picture that shows H-bridge shield from sparkfun based on L298 H bridge.


Robot Motor control using Arduino

As you can see the L298 H bridge is at the center of the board. Surrounding it, supporting components like diodes, LEDs, hex inverter, capacitor and there are supply and header mounting holes.

The picture below shows the typical example of where the inputs from arduino to the shield goes, where to connect the motors and where to connect supply.

Robot Motor control using Arduino

The shield has two ports A and B to connect two motors. There are LEDs on either sides of the port A and B that indicates the motor directions. It has two power supply- one from external at VIN inputs and one from arduino. Then final there are 4 inputs from the Arduino. Two are for motor A and two are for motor B. The control for motor A is the direction via the digital pin and the speed of the motor via the PWM(Pulse Width Modulation).

As you may also have noticed the board pins matches with the Arduino board. So by soldering some header pins you can put the this H-bridge board on the top of the Arduino and thats why it is called shield. The following picture shows example.

If you went to good electronics or electrical engineering program you should have learn about how to solder parts such as headers and power supplies. If not, this is not hard and you can do this easily at home.

This was just basic introduction to what is H-bridge, what is a H-bridge shield and how to connect it with the arduino.

how to turn on and off a single motor with a switch

Now first you will learn how to turn on and off a single motor with a switch. Below shows the schematic to connect a motor to port A

After connecting the parts you should have similar arrangement like the following.

Robot Motor control using Arduino

So essentially, the switch is connected to digital pin 10 on the shield. But this is same as connecting to the digital pin 10. So by writing arduino program to turn on/off the motor by monitoring the switch state we can turn on and off the motor.

The following Arduino Program monitors the switch state and turns on/off motor accordingly.


The next arduino motor tutorial shows you how to control speed of motor using potentiometer.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Leave a Reply

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

Microcontroller Simulation Project with Proteus for beginners

Microcontroller Simulation Project with Proteus for beginners

Very simple way to understand Structure in C