Running LEDs using Maths

This is a simple program using a mathematical formula for 8051 MUC for running effect of 8 LEDs connected to PORT1 from P1^0 to P1^7.
Code written by: Yash Vidyasagar

#include <reg51.h>
int i,j=1;

// User defined code for delay in the program
void delay(unsigned int msec)
{
  int a, b;
   for(a=0;a<msec;a++)
   {
    for(b=0;b<128;b++);
   }
}

int main()
{
  while(1)
  {
    for(i=0;i<10;i++)
    {
      P1=j;
      delay(1000);
      j=j*2;
			
    if(j>128)
    {
      j=1;
    }
   }	
  }
}

Check other oustanding projects using 8051 microcontroller.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.