DC motor interfacing with 8051 | 8051 tutorial in tamil





Source Code:-



#include<reg51.h>

sbit IN1=P2^0;   //   naming IN1 for P2.0 to connect the in1 pin of the L293d

sbit IN2=P2^1;   //   naming IN2 for P2.1 to connect the in2 pin of the L293d

void Delay(unsigned int itime);

void main()

{

P2=0x00;

while(1)

{

IN1=0;   // clockwise direction

IN2=1;

Delay(1000);

IN1=1;   // clockwise direction

IN2=0;

Delay(1000);

}

}



void Delay(unsigned int itime)

{

    unsigned int i,j;

    for(i=0;i<1275;i++)

    for(j=0;j<itime;j++);

}

Comments