*Σύντομα και στα Ελληνικά
Introduction
The L293D is a 16-pin Motor Driver IC which can control a set of two DC motors simultaneously in any direction.
The L293D is designed to provide bidirectional drive currents of up to 600 mA (per channel) at voltages from 4.5 V to 36 V (at pin 8!). You can use it to control small dc motors - toy motors. Sometimes it can be extremely hot.
The L293D is designed to provide bidirectional drive currents of up to 600 mA (per channel) at voltages from 4.5 V to 36 V (at pin 8!). You can use it to control small dc motors - toy motors. Sometimes it can be extremely hot.
What you will need - Hardware
For this tutorial you will need:
|
The Circuit
The connections are easy, see the image above with the breadboard circuit schematic.
The code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | //L293D //Motor A const int motorPin1 = 5; // Pin 14 of L293 const int motorPin2 = 6; // Pin 10 of L293 //Motor B const int motorPin3 = 10; // Pin 7 of L293 const int motorPin4 = 9; // Pin 2 of L293 //This will run only one time. void setup(){ //Set pins as outputs pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); pinMode(motorPin3, OUTPUT); pinMode(motorPin4, OUTPUT); //Motor Control - Motor A: motorPin1,motorpin2 & Motor B: motorpin3,motorpin4 //This code will turn Motor A clockwise for 2 sec. digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); delay(2000); //This code will turn Motor A counter-clockwise for 2 sec. digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); delay(2000); //This code will turn Motor B clockwise for 2 sec. digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); delay(2000); //This code will turn Motor B counter-clockwise for 2 sec. digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); delay(2000); //And this code will stop motors digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); } void loop(){ } |
Download the code from here and open it with Arduino IDE.
|
|
You can keep playing with that, for example try to combine parts of code to move both motors simultaneously.
Try to use analogWrite(pin, PWM value) instead digitalWrite(pin, HIGH/LOW) to control the speed of motors!
Try to use analogWrite(pin, PWM value) instead digitalWrite(pin, HIGH/LOW) to control the speed of motors!
Well done!
You have successfully completed one more Arduino "How to" tutorial and you learned how to use the L293D motor driver IC to control two dc motors with the Arduino uno board.
I hope you liked this, let me know in the comments!
I hope you liked this, let me know in the comments!