![]() |
Here In this article, we will learn about DC motors and how these motors can be controlled using an Arduino board with very little programming. We are also going to use an L293D motor controller IC. This is very important to use the controller board because we can not connect the DC motors directly to the Arduino board. The power supply from an Arduino board is 3.3V and 5V which are insufficient to power a DC motor of 9V. If we try using Arduino there is a high risk of losing the Arduino board. Architecture L293D Motor Driver IC![]() L293D IC On this IC there is a total of 16 pins. The Upper 8 pins can control a single DC motor and the lower can also control another DC motor. A total of 2 DC motors can be controlled using an L293D IC. The pin description is given below.
Connection of all ComponentsList of all the components
Step 1: Motor and L293D connectionsConnection both the motors directly to the motor ports or pins on the L293D motor driver IC. Named as Output 1 & Output 2 for motor 1 and Output 3 & Output 4 for motor 2. Step 2: Battery and L293D connectionsThe 9V battery is connected to the breadboard, and the Power 1 and Power 2 of the IC can be connected to the +terminal on the breadboard. The GND from the upper and GND from the lower of the IC can be connected to the -ve terminal on the breadboard. Step 3: Arduino Board and L293D connectionsConnect the IC pins as mentioned. Enable pin to digital pin 13 on Arduino, input 1 to digital pin 12, and input 2 to digital pin 11 on Arduino. Now for the upper side of the IC, connect enable pin to pin 3, input 3 to digital pin 4, and input 4 to digital pin 5 on the Arduino board. Check your connection from the below image.All the connections we have done till now can be seen in the image below. Use this image to cross-verify your project before executing it yourself. ![]() All connections on Arduino Control DC Motors Using L293D IC and ArduinoAfter all the connections are done properly we can now move to the coding part on the Arduino board. Here we are using the free Arduino simulator tinkercad. After importing and connecting all the components as mentioned above, we have various cases of operating the motors. Case 1: Rotate Both MotorsHere we will rotate the motors, in our case both motors are rotating anti-clockwise. ![]() GIF: Motor anti-clockwise rotation C++
Case 2: Reverse the RotationSimply, change the HIGH to LOW and LOW to HIGH. ![]() GIF: Motor direction reversed C++
Case 3: Rotate M1 and Stop M2Both digitalWrites for motor 2 will become LOW for it to stop. Similarly, use it for stopping M1 and rotating M2. ![]() GIF: M2 Stopped C++
Case 4: Control Motor SpeedHere in this article, the pins on Arduino we are using are digital PWM (Pulse Width Modulation). These pins allow us to control the signal strength using a pre-defined function analogWrite(). ![]() GIF: Speed of motor 2 is reduced C++
|
Reffered: https://www.geeksforgeeks.org
Arduino |
Related |
---|
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |