Arduino Workshop-Using an L293D Motor Driver IC

In this project, we are going to use a very popular motor driver IC called an L293D. The advantage of using this chip is that we can control two motors at the same time, as well as control their direction. The chip can also be used to control a stepper motor

Required Component of L293D Motor Driver IC:

1.Arduino
 
 
 
 
 
 
 
 
 

This book will help you to gain more knowledge about Arduino

Beginning Arduino

Circuit diagram:

First, make sure your Arduino is powered off by unplugging it from the USB cable. Now take the required parts and connect them up as in Figure Using an L293D Motor Driver IC. Again, check the circuit thoroughly before powering it up. The L293D can get hot when in use, and therefore a heatsink is recommended. Glue the heatsink to the top of the chip using special thermal epoxy glue, thermally conductive double-sided tape, or use a clip-on style heat sink. The larger the heatsink, the better. Be warned that the temperature can get hot enough to melt the plastic on a breadboard or any wires touching it. Do not touch the heatsink as you may burn yourself and ensure you do not leave the circuit powered up and unattended in case it overheats
 Using an L293D Motor Driver IC 
Using an L293D Motor Driver IC

Code L293D Motor Driver IC:

#define switchPin 2 // switch input
#define motorPin1 3 // L293D Input 1
#define motorPin2 4 // L293D Input 2
#define speedPin 9 // L293D enable pin 1
#define potPin 0 // Potentiometer on analog Pin 0
int Mspeed = 0; // a variable to hold the current speed value
void setup() {
//set switch pin as INPUT
pinMode(switchPin, INPUT);
// set remaining pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(speedPin, OUTPUT);
}
void loop() {
Mspeed = analogRead(potPin)/4; // read the speed value from the
potentiometer
analogWrite (speedPin, Mspeed); // write speed to Enable 1 pin
if (digitalRead(switchPin)) { // If the switch is HIGH, rotate
motor clockwise
digitalWrite(motorPin1, LOW); // set Input 1 of the L293D low
digitalWrite(motorPin2, HIGH); // set Input 2 of the L293D high
}
else { // if the switch is LOW, rotate motor anti-clockwise
digitalWrite(motorPin1, HIGH); // set Input 1 of the L293D low
digitalWrite(motorPin2, LOW); // set Input 2 of the L293D high
}
}
Once the code has finished uploading, set the potentiometer at its midpoint, and plug in the external power supply. The motor will now rotate and you can adjust its speed by turning the potentiometer. To change the direction of the motor, first set the speed to minimum, then flick the switch. The motor will now rotate in the opposite direction. Again be careful of that chip, as it will get very hot once powered up.

All Arduino tutorial available Click here

 ALL ARDUINO TUTORIAL 

No comments

Theme images by Dizzo. Powered by Blogger.