Monday, October 1, 2012

LED Sand Tough Pattern




Refer 'LED Basic Circuit' in 'Embedded Systems Circuits' Label


#include<reg51.h>
#include<intrins.h>
void ms_delay(unsigned int a)
{
unsigned char b=255;
for(;a-->0;)
for(;b-->0;)
_nop_();
}

void main()
{

 unsigned char i,a,s,b,j,c;
 while(1)
 {
  a=0xff;
  b=0;
  for(i=0;i<8;i++)
  {
   c=0xfe;
   for(j=0;j<(8-b);j++)
   {
    P1=c&(a>>b);
    c=c<<1;
    c=c+0x01;
    ms_delay(500);
   }
   b++;
  }
  if(P1==0X00)
  {
   a=0xff;
   b=0;
   for(i=0;i<8;i++)
   {
    c=0x01;
    for(j=0;j<(8-b);j++)
    {
     s=c^(a>>b);
     P1=~s; 
     c=c<<1;
     ms_delay(500);
    }
    b++;
   }
  }
 }
}
  


0 comments:

Post a Comment