LED effect with micro 89c51

Pretty simple LED effect with a simple code and schematic


#include
#define first P1
#define second P2
//sbit first P1^0
//sbit second P2^0
void wait()
{
int i,j;
for(i=0;i<=1000;i++)
for(j=0;j<=10;j++);
}
main()
{
unsigned int i; /* Delay var */
unsigned char j,m; /* LED var */
while (1)
{
for(m=0x01;m!=0xff;m=m(m<<1))
{
for(i=1;i<=7;i++)
{ /* Loop forever */
for (j=m; j!= 0x00; j<<=i) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
P1 = j; /* Output to LED Port */
wait (); /* call wait function */
}
P1=0;
for (j=m; j!=0x00; j<<=i) { /* Blink LED 6, 5, 4, 3, 2, 1 */
P2 = j; /* Output to LED Port */
wait ();
} /* call wait function */
P2=0;
}
}
}
}


schematic :
Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

Comments

Popular posts from this blog

Nokia dot Matrix LCD Interfacing with 89c51( 8051 core)

8051 Development Setup:MIDE-51 Installation