Microcontroller › 8051 › In what form signal is given to AT89c51 mc’s input › following program is correct
following program is correct for rotating the stepper motor half revolution in clock wise and anti-clock wise.?
My aim is to use this stepper motor to close and open the Railway crossing gate..
#include<reg51.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0;
sbit sense2=P1^1;
void main ()
{
int i;
P1=0x03;
{
if ((sense1=='1')&& (sense2!='1'))
{
for (i=0;i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x02;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x08;
MSDelay (10);
}
}
sense1=0;
if ((sense2=='1') && (sense1!='1'))
{
for (i=0; i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x08;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x02;
MSDelay (10);
}
}
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y;
for(x=0; x<1275;x++)
for(y=0;y<value;y++);
}