Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

IR based traffic light control system

Status
Not open for further replies.

himesh

Newbie level 1
Joined
Mar 2, 2015
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Activity points
0
hallo Iam a begineer. I want to do a project named IR based traffic light control system using 8051, so i find a embedded c program, but it didn't works. Can anyone plz help me. The program is given here, plz correct me or give me a fresh program to do my project. Thankyou in advance

# include<reg51.h>
# define density_level P1
//void green_delay();
//Lights declaration
sbit ar = P0^0;
sbit ag = P0^1;
sbit br = P0^2;
sbit bg = P0^3;
sbit cr = P0^4;
sbit cg = P0^5;
sbit dr = P0^6;
sbit dg = P0^7;
//sensors declarartion
sbit IRaa=P1^0;
sbit IRab=P1^1;
sbit IRba=P1^2;
sbit IRbb=P1^3;
sbit IRca=P1^4;
sbit IRcb=P1^5;
sbit IRda=P1^6;
sbit IRdb=P1^7;
int a[]={
void main()
{
P1=0XFF;
P3=0X00;
P0=0X00;



P2=0X00;
ar=1;
br=1;
cr=1;
dr=1;
while(1)
{
int check_high;
bit a=0,b=0,c=0,d=0,high=0;
int lane_a,lane_b,lane_c,lane_d;
for (check_high=0;check_high<3;check_high++)
{
switch (density_level)
{
case 0XFC :
if(a==0)

{ ar = 0;
a=1;
for(lane_a=0;lane_a<9;lane_a++)
{
ag = 1;
}



ag = 0;
}
break;
case 0XF3 :
if(b==0)
{ br = 0;
b=1; for(lane_b=0;lane_b<9;lane_b++)
{
bg = 1;
}
}
bg = 0;
break;
case 0XCF :
if(c==0) {
cr = 0;
c=1;
for(lane_c=0;lane_c<9;lane_c++)
{
cg = 1;
}
}
cg = 0;
break;
case 0X3F :
if(d==0)
{
dr = 0;



d=1;
for(lane_d=0;lane_d<9;lane_d++) {
dg = 1;
} }

dg = 0;
break;
}
P0 = P0&0XFF;
}
} }
/*{
while(high==1)
{
int check2;
for (check2=0;check2<2;check2++)
{
{
if(IRaa==0) //check lane a
{
if(IRab==0)
{
ar = 0;
ag = 1;
green_delay();
ag = 0;
}




else
{
ag = 0;
//ay = 1;
//yellow_delay();
//ay = 0;
ar = 1;
}}}
{
if(IRba==0) //check lane b
{
if(IRbb==0)
{
br = 0;
bg = 1;
}
else
{
bg = 0;
//by = 1;
//yellow_delay();
//by = 0;
br = 1;
}}}
{
if(IRca==0)






//check lane c
{
if(IRcb==0)
{
cr = 0;
cg = 1;
}
else

{
cg = 0;
//cy = 1;
//yellow_delay();
//cy = 0;
cr = 1;
}}}
{
if(IRda==0)
//check lane d
{
if(IRdb==0)
{
dr = 0;
dg = 1;
}
else
{
dg = 0;
//dy = 1;
//yellow_delay();

//dy = 0;
dr = 1;
}}}}}}
}*/
/*void green_delay()
{
int y;
for (y=0; y<1000; y++);
}
 

It is a group programming practice to always provide comments for your code blocks for others to understand. Edit your post to enable help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top