You are on page 1of 2

#include<reg51.

h>
//for
sbit a =
sbit b =
sbit c =
sbit d =

stepper
P2^0;
P2^1;
P2^2;
P2^3;

//for DC
sbit En = P1^0;
sbit X =P1^1;
sbit Y = P1^2;
void Delay (unsigned int itime);
unsigned int count=0;
void main()
{

a=0;
b=0;
c=0;
d=0;
En=0;
X=0;
Y=0;
while(1)
{
for(count=0;count<20;count++)
{
d=0;
a=1;
b=0;
Delay(100);
a=1;
b=1;
Delay(100);
a=0;
b=1;
Delay(100);
b=1;
c=1;
Delay(100);
b=0;
c=1;
Delay(100);
c=1;
d=1;
Delay(100);

//for delay

c=0;
d=1;
Delay(100);
d=1;
a=1;
Delay(100);

}
d=0;
a=0;
X=1;
//upwards
Y=0;
En=1;
Delay(1000);
Delay(1000);
Delay(1000);
Delay(1000);
En=0;
Delay(1000);
Delay(1000);
Delay(1000);
Delay(1000);
X=0;
//downwards
Y=1;
En=1;
Delay(1000);
Delay(1000);
En=0;
Delay(1000);
Delay(1000);
Delay(1000);
Delay(1000);
}
}

void Delay(unsigned int itime)


{
unsigned int i,j;
for(i=0;i<itime;i++);
for(j=0;j<1275;j++);
}

You might also like