Microcontroller › 8051 › L293D interfacing with 8051 › /*motor.c*//*try this out ,
March 25, 2013 at 6:25 am
#9369
Arjun Vaghani
Participant
/*motor.c*/
/*try this out , it’s very simple*/
/*LCD is not necessary for L293D’s interfacing with AT89S52, So i have not given, but u can add that code separately*/
/*program-start*/
#include<reg51.h>
main()
{
while(1)
{
unsigned char t;
t=P1&0x0f; //read the data from port P1
switch(t)
{ /*block for taking action according to input*/
case 0x02:P2=0x85; /*forward*/
break;
case 0x04:P2=0x86; /*left*/
break;
case 0x06:P2=0x89; /*right*/
break;
case 0x08:P2=0x8A; /*backward*/
break;
case 0x05:P2=0x00; /*stop*/
break;
case 0x00:P2=0x00; /*no input*/
break;
}
}
}
/*In Diagram Shown Below, by Configuring Port P1 for Different Input Combinations , U can get the Action Performed by the DC Motor, i.e Desired Motion.*/