Write an Embedded C program to Stepper motor interface in 8051
#include"reg51.h"
void
main(void)
{
unsigned
int i;
while(1)
{
P1=0x06;
for(i=0;i<30000;i++);
P1=0x0A;
for(i=0;i<30000;i++);
P1=0x09;
for(i=0;i<30000;i++);
P1=0x05;
for(i=0;i<30000;i++);
}}
Write an Embedded C program to Stepper motor interface in 8051 using
Switch
#include"reg51.h"
sbit SW=P2^7;
void MSDelay(unsigned
int);
void main(void)
{
SW = 1;
while(1)
{
if(SW==0)
{
P1=0x06;
MSDelay(50);
P1=0x0A;
MSDelay(50);
P1=0x09;
MSDelay(50);
P1=0x05;
MSDelay(50);
}
else
{
P1=0x00;
MSDelay(50);
}
}
}
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}
0 comments:
Post a Comment