Search

Friday, September 17, 2010

8051 MICROCONTROLLER PROGRAM - PENDULUM/STACK PROGRAM IN EMBEDDED C

#include
void MSdelay(unsigned int itime);
void main()
{
unsigned int i,n,s,r[]={1,2,4,8,16,32,64},j;
while(1)
{
P1=0x01;
MSdelay(500);
for(i=0;i<7;i++)
{
P1=P1<<1;
MSdelay(500);
}
n=7;
s=128;
while(n>0)
{
for(j=0;j
{
P1=s+r[j];
MSdelay(500);
if(j==n-1)
{
s=s+r[n-1];
n--;
}
}
}
}
}

void MSdelay(unsigned int itime)
{
unsigned int k,l;
for (k=0;k
for (l=0;l<1275;l++);
}

No comments: