8051 Microcontroller based Pendulam operation


DISCRIPTION:-

In this Project Multi-Pattern Running light is used to generate several designs of Running Lights. We use ten LED’s for display. The designs can be selected by using switches UP and DOWN. The 8 bit Microcontroller is used to control all the operations. It control the LED’s though the Ports.

The above system is monitored and controlled by the 8 bit microcontroller 8051. The Microcontroller continuously monitors the Switches and switch on/off the LED’s according to the Program. The Power for the circuit is derived from the Step down transformer and the 5V regulator IC7805. The regulator IC produces a constant 5v output.

CODE:-

#include<reg51.h>

/**********************STARTING OF PROGRAM FUNCTION************************************************/

//_______________________DELAY SUBROUTINE_________________________________________________/

void delay(int a)
{
int i,j;
for(i=0;i<a;i++)
for(j=0;j<1275;j++);                          //CREATING DELAY BY INSTRUCTION
}

/***************************MAIN PROGRAM*********************************************************/
void main()
{
int k;
start:                     //P1 PORT AS OUTPUT PORT,WITH VARIABLE K & SHIFT THE POSITION OF LED AMONG 8 PIN OF P1
while(1)
{
//______________ CODE FOR SHIFTING(LED GLOWING) IN DECREMENT ORDER ONE BY ONE ___________/

for(k=0x80;k>=0x01;k>>=1)     //LOOP FOR SHIFTING FROM 1-POSITION to LAST POSITION IN FORWARD

DIRECTION

{
P1=~k;                                                                            //LED GLOW AT P1 PORT FOR CORRESPONDIG POSITION OF K
delay(50);
if(k==0x01)                                     //CONDITION,WHEN LAST POSITION OCCUR DURING TRAVELLING IN FORWARD

DIRECTION
{
for(k=0x01;k<=0x40;k<<=1)                                                   //LOOP FOR SHIFTING IN REVERSE DIRECTION, FROM LAST

POSITION TO 2-POSITION
{
P1=~k;
delay(50);                                                                  //CALLING DELAY SUBROUTINE
if(k==0x40)                                                             //CONDITION,WHEN 2-POSITION OCCUR DURING TRAVELLING IN

REVERSE DIRECTION
{
for(k=0x40;k>=0x02;k>>=1)                                                  //LOOP FOR SHIFTING IN FORWARD DIRECTION, FROM 2-

POSITION TO 2nd LAST POSITION
{
P1=~k;
delay(50);
if(k==0x02)                                                               //CONDITION,WHEN 2nd LAST POSITION OCCUR DURING TRAVELLING IN

FORWARD DIRECTION
{
for(k=0x02;k<=0x20;k<<=1)                                                 //LOOP FOR SHIFTING IN REVERSE DIRECTION,FROM 2nd LAST

POSITION TO 3rd POSITION
{
P1=~k;
delay(50);
if(k==0x20)                                                                                     //CONDITION WHEN 3rd POSITION OCCUR DURING

TRAVELLING IN REVERSE DIRECTION
{
for(k=0x20;k>=0x04;k>>=1)                                                   //LOOP FOR SHIFTING IN FORWARD DIRECTION,FROM 3rd

POSITION TO 6th POSITION
{
P1=~k;
delay(50);
if(k==0x04)                                                                                             //CONDITION,WHEN 6th POSITION OCCUR DURING

TRAVELLING IN FORWARD DIRECTION
{
for(k=0x04;k<=0x10;k<<=1)                                                     //LOOP FOR SHIFTING IN REVERSE DIRECTION,FROM 6th

POSITION TO 4th POSITION
{
P1=~k;
delay(50);
if(k==0x10)                                                                                    //CONDITION WHEN 4th POSITION OCCUR DURING TRAVELLING

IN REVERSE DIRECTION
{
for(k=0x10;k>=0x08;k>>=1)                                                           //LOOP FOR SHIFTING IN FORWARD DIRECTION,FROM 4th

POSITION TO 5th POSITION
{
P1=~k;
delay(50);
if(k==0x08)                                                                                      //CONDITION,WHEN 5th POSITION OCCUR DURING

TRAVELLING IN FORWARD DIRECTION
{

/********CODE FOR SHIFTING(LED GLOWING) IN INCREMENT ORDER ONE BY ONE******************************/

for(k=0x08;k<=0x10;k<<=1)                                                           //LOOP FOR IN REVERSE DIRECTION,FROM 5th POSITION

TO 4th POSITION
{
P1=~k;
delay(50);
if(k==0x10)                                  //CONDITION,WHEN 4th POSITION DURING TRAVELLING IN REVERSE DIRECTION
{
for(k=0x10;k>=0x04;k>>=1)                                        //LOOP FOR SHIFTING IN FORWARD DIRECTION,FROM 4th

POSITION TO 6th POSITION
{
P1=~k;
delay(50);
if(k==0x04)                      //CONDITION,WHEN 6th POSITION OCCUR DURING TRAVELLING IN FORWARD DIRECTION
{
for(k=0x04;k<=0x20;k<<=1)                           //LOOP FOR SHIFTING IN REVERSE,FROM 6th POSITION TO 3rd POSITION
{
P1=~k;
delay(50);
if(k==0x20)                           //CONDITION,WHEN 3rd POSITION OCCUR DURING TRAVELLING IN REVERSE DIRECTION
{
for(k=0x20;k>=0x02;k>>=1)                          //LOOP FOR SHIFTING IN FORWARD,FORM 3rd POSITION TO 7th POSITION
{
P1=~k;
delay(50);
if(k==0x02)                             //CONDITION,WHEN 7th POSITION OCCUR DURING TRAVELLING IN FORWARD DIRECTION
{
for(k=0x02;k<=0x40;k<<=1)                             //LOOP FOR SHIFTING IN REVERSE,FROM 7th POSITION TO 2nd POSITION
{
P1=~k;
delay(50);
if(k==0x40)                              //CONDITION,WHEN 2nd POSITION OCCUR DURING TRAVELLING IN REVERSE DIRECTION
{
for(k=0x40;k>=0x01;k>>=1)                         //LOOP FOR SHIFTING IN FORWARD,FROM 2nd POSITION TO 8th POSITION
{
P1=~k;
delay(50);
if(k==0x01)                        //CONDITION,WHEN 8th POSITION OCCUR DURING TRAVELLING IN FORWARD DIRECTION
{
for(k=0x01;k<=0x80;k<<=1)                               //LOOP FOR SHIFTING IN REVERSE,FROM 8th POSITION TO 1st POSITION
{
P1=~k;
delay(50);
if(k==0x80)                               //CONDITION WHEN 1st POSITION OCCUR DURING TRAVELLING IN REVERSE DIRECTION
{
goto start;                       //CODE FOR REPEATING ALL ABOVE PROCESS FROM STARTING,SO JUMP TO “START” LEVEL
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

VEDIO:-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s