Monday, October 1, 2012

LED Sand Glass 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,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++;
  }   
 }  
}

0 comments:

Post a Comment