How traffic signal controller by mc

Status
Not open for further replies.

svinoth86

Newbie level 6
Joined
Nov 13, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,420
How traffic signal controller by mc.........................................................................................................................................................................................

---------- Post added at 14:11 ---------- Previous post was at 14:10 ----------

#include <REGX51.H>

int i;

void timer_init(int j)
{

for(i=0;i<j*20;i++)
{
TH1=0x4b;
TL1=0xfd;
TR1=1;
while(TF1==0);
TF1=0;
}

}
void traffic_init()
{
int k=0;
P0=0x49;P2=0x08;
timer_init(10);
P0=0x89;P2=0x04;
timer_init(2);

P0=0x09;P2=0x03;
timer_init(10);
P0=0x91;P2=0x02;
timer_init(2);

if(P1_0==1)
k=0;
P0=0x61;P2=0x02;
timer_init(10+k);k=0;
P0=0x52;P2=0x02;
timer_init(2);

if(P1_1==1)
k=0;
P0=0x4C;P2=0x02;
timer_init(10+k);k=0;
P0=0x4a;P2=0x04;
timer_init(2);
}

void traffic_on()
{
timer_init(1);P2=P0=255;
timer_init(1);P2=P0=0;
timer_init(1);P2=P0=255;
timer_init(1);P2=P0=0;
}

void main()
{
P2=P0=0x00;
// P1=0;
TMOD=0x10;
traffic_on();
while(1)
{
traffic_init();
}
}
 

I think you should use code tags...anyway I am doing it.

Code:
#include <REGX51.H>

int i;

void timer_init(int j)
{

for(i=0;i<j*20;i++)
{
TH1=0x4b;
TL1=0xfd;
TR1=1;
while(TF1==0);
TF1=0;
}

}
void traffic_init()
{
int k=0;
P0=0x49;P2=0x08;
timer_init(10);
P0=0x89;P2=0x04;
timer_init(2);

P0=0x09;P2=0x03;
timer_init(10);
P0=0x91;P2=0x02;
timer_init(2);

if(P1_0==1)
k=0;
P0=0x61;P2=0x02;
timer_init(10+k);k=0;
P0=0x52;P2=0x02;
timer_init(2);

if(P1_1==1)
k=0;
P0=0x4C;P2=0x02;
timer_init(10+k);k=0;
P0=0x4a;P2=0x04;
timer_init(2);
}

void traffic_on()
{ 
timer_init(1);P2=P0=255;
timer_init(1);P2=P0=0;
timer_init(1);P2=P0=255;
timer_init(1);P2=P0=0;
}

void main()
{
P2=P0=0x00;
// P1=0;
TMOD=0x10;
traffic_on();
while(1)
{
traffic_init();
}
}

BTW,what is it? I mean is it a complete project,if so then you should post the schematic with it and if you are having any problem then you should post your problem with it.May be I just didn't understood...:???:

Good Luck
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…