Motors are widely found in toys and are very crucial part in automation and robotics.This tutorial will help you to interface a motor with an Arduino .The arduino board,s digital pins are suitable for low power devices like led and other sensors but motors draw more power and hence when used directly may burn the board or motor wont interact.We use a H-bridge to control the direction of rotation of motors and speed.
Step 1: COMPONENTS
1.GEAR MOTOR OR BO MOTOR
2. L293D IC
5.ARDUINO WITH USB CABLE
6.9V POWER SUPPLY
Step 2: WIRING THE COMPONENTS
wire the components as shown in the diagram
Step 3: THE H-BRIDGE
The h-bridge consists of 16 pin,divided into 8 pins for both sides.
1.Pin 1,9 is used to enable the IC and connected to 5V
2..Pin 4,5,13,12 is connected to ground
3.Pin 2,7,15,11 is for input and output for the following pin is3,6,14,11
4.pin 16 is VCC and must be connected to 5V
5.Pin 8 is the control pin for controlling the speed of the motor the maximum permitted voltage is 9V,varying the voltage results in variation of speed.
LOGIC TABLE FOR H-BRIDGE
INPUT1 INPUT2 RESPONSE
1 0 CLOCKWISE
0 1 ANTICLOCKWISE
0 0 BRAKING
1 1 BRAKING
6. For this tutorial I will be using only one motor.
5V -LOGIC LEVEL-HIGH OR 1
0V-LOGIC LEVEL-LOW OR 0
Step 4: CODING
I have attached the code for this tutorial and the coding is self explanatory and very easy if u already know the basic syntax and working.
Step 5: WIRING
1.wire the following as shown in the diagram.for your reference i have attached a photo of l293d IC.Pin 8 should be given a separate 9v power.connect +ve pin of 9v battery to pin 8 and connected all the ground(-ve pin of 9v battery) and gnd pins used in the arduino together.If you are using an external power source then you must have a common ground source or else the circuit wont work.
Step 6: SIMULATION AND END RESULT
for your better understanding I have added a simulation video please check that out
Step 7: CONCLUSION
Congo on completing the tutorial hope you have done it if you have any doubts/queries feel fry to comment I will reply ASAP.