//instead of 270 enter your desired angle.
// this code is for unipolar 6 terminal stepper motor.
# include
# include
void delay(void);
void main (void)
{
int i;
for(i=0;i<(270/(1.8*4));i++)
{
P2_0=0;
delay();
P2_0=1,P2_1=0;
delay();
P2_1=1,P2_2=0;
delay();
P2_2=1,P2_3=0;
delay();
P2_3=1;
}
for(i=0;i<(270/(1.8*4));i++)
{
P1_0=0;
delay();
P1_0=1,P1_1=0;
delay();
P1_1=1,P1_2=0;
delay();
P1_2=1,P1_3=0;
delay();
P1_3=1;
}
for(i=0;i<(180/(1.8*4));i++)
{
P3_0=0;
delay();
P3_0=1,P3_1=0;
delay();
P3_1=1,P3_2=0;
delay();
P3_2=1,P3_3=0;
delay();
P3_3=1;
}
for(i=0;i<(270/(1.8*4));i++)
{
P2_3=0;
delay();
P2_3=1,P2_2=0;
delay();
P2_2=1,P2_1=0;
delay();
P2_1=1,P2_0=0;
delay();
P2_0=1;
}
for(i=0;i<(270/(1.8*4));i++)
{
P1_4=0;
delay();
P1_4=1,P1_5=0;
delay();
P1_5=1,P1_6=0;
delay();
P1_6=1,P1_7=0;
delay();
P1_7=1;
}
while(1);
}
void delay(void)
{
TMOD=0x10;
TL1=0x58;
TH1=0x9E;
TR1=1;
while ( TF1 == 0 );
TR1=0;
TF1=0;
}
No comments:
Post a Comment