Arduino with L293D motor driver
This is part of the starter blog for Arduino basics. Check out here to see all of them.
A motor usually requires a lot more current than what is supplied by an arduino. Arduino UNO typically supplies 50mA per pin whereas a simple dc motor requires almost 800mA current (This is considering the simple plastic geared motor shown below. For metal geared ones, it requires way more current and will require other motor drivers like L298N) So a motor driver is used to take care of the current requirement.
L293D motor driver works on the principle of dual H-bridge. This allows the motor to rotate both clockwise and anti clockwise. With a dual H-bridge, it can control two motors simultaneously. Below is the pin diagram of the IC
We will be using only one side and run a single motor. Here Input1 and Input2 are connected to Arduino pins and Output1 and Output2 are connected to a motor. The working is like this –
- Input1 is HIGH and Input2 is LOW -> Motor runs clockwise.
- Input1 is LOW and Input2 is HIGH -> Motor runs counter-clockwise.
Note that clockwise and counter-clockwise are relative, i.e. it depends on which direction you are considering. Alright, so lets get started!
~What you need~
You will need the following parts.
- Arduino UNO
- L293D motor driver
- Jumper wires
You can also use a L293D Motor driver module if you want. It will make things even simpler, as you wont have to wire the IC. Below is an image of the parts.
~What to do~
- Wire the following circuit on the breadboard.
- Type the following code in the IDE and upload it.
- That’s it! Your Motor turns clockwise for 5 sec and anti clockwise for 5 sec.
You can compile the motor driver IC into a module for easy use. Or you can simply use a complete module available in the market. Check out the following links as well..