Arduino:How to use motor driver module L293D

       Motor Driver L293D module 




This motor driver module has 4 input pins which will be connected to the arduino and 4 output pins which will be connected with the two motors,and there are 3 more pins which is 12v input ,5v input and a GND(negative terminal)
the module can be powered by 12v supply or a 5v supply.and it can control  2 motors

CODE to upload


int motorpin1=5;
int motorpin2=6;
int motorpin3=7;
int motorpin4=8;

void setup()
{
pinMode(motorpin1,OUTPUT);
pinMode(motorpin2,OUTPUT);
pinMode(motorpin3,OUTPUT);
pinMode(motorpin4,OUTPUT);

}
void loop()
{

digitalWrite(motorpin1,HIGH);
digitalWrite(motorpin2,LOW);
digitalWrite(motorpin3,HIGH);
digitalWrite(motorpin4,LOW);

}




After uploading the code ,the motors will start spinning in CLOCKWISE direction,this is because of the HIGH ,LOW sequence written in the code
You can also change the direction of spinning of the motor by just changing the the code sequence as follows-:


For clockwise spin:-

digitalWrite(motorpin1,HIGH);
digitalWrite(motorpin2,LOW);
digitalWrite(motorpin3,HIGH);
digitalWrite(motorpin4,LOW);


For Anticlockwise spin:-

digitalWrite(motorpin1,LOW);
digitalWrite(motorpin2,HIGH);
digitalWrite(motorpin3,LOW);
digitalWrite(motorpin4,HIGH);

Here,
HIGH 
LOW ,corresponds to clock spin

where as 
LOW
HIGH ,correspond to clock spin

Just change the sequences as according to your project working and you will get the desired results!!

Thanks for reading ,hope you are done with the motor driver project
If still there is a problem in spinning or any thing else just write in the comment box.

Comments

Popular posts from this blog

Arduino:How to program an arduino using loop statements

Automatic Door Locking with Arduino

Arduino:How to make a RC car with arduino