The figure below shows the intersection of a main highway wi


The figure below shows the intersection of a main highway with secondary axes road. Vehicle detections sensors are placed along lanes C and D (main road) and lane A and B (access road) The sensor are LOW (0) when no vehicle is present and HIGH(1) when a vehicle is present. The intersection traffic is to be controlled according to the following logic. The East-West (E-W) traffic light will be green whenever both lanes C and D are occupied. The East West (E-W) light will be green whenever either C or D is occupied lanes A and B are not both occupied. The North-South light will be green whenever both lanes A and B are occupied but C and D are not both occupied. The North-South (N-S) light will also be green when either A and B is occupied but C and D are both vacant. The East-West (E-W) will be green when no vehicles are present. Using the sensor outputs a, b, c and D as inputs..design a logic circuit to control the traffic light. There should be two outputs, N-S and E-W, which go HIGH when the corresponding light is to be green. Simply the circuit as much as possible.

Solution

Source Code

C Program to Traffic Light using 8051

#include <reg51.h>
sbit RED1 =    P1^0;
sbit YELLOW1 =   P1^1;
sbit GREEN1 =   P1^2;
sbit RED2 =   P3^2;
sbit YELLOW2 =   P3^3;
sbit GREEN2 =   P3^4;
sbit RED3 =   P3^5;
sbit YELLOW3 =   P3^6;
sbit GREEN3 =   P3^7;
sbit RED4 =   P1^3;
sbit YELLOW4 =   P1^4;
sbit GREEN4 =   P1^;5

void Delay (void)

{

    unsigned int i, j;

    for (i=0; i<300; i++)

         for (j=0; j<700; j++);

}

void Super Delay ( )

{

    unsigned int i ;

    for (i=0 ; i<30; i++)  

         Delay( );

}

void main ( )

{

    PD =   0;

    while (1)

    {

         R1 =   0; G1 =   1; Y1 =   0; / Understand RED1 is written as R1 and so on through my program.

         R2 = 1; G2 =   0; Y2 =   0;

         R3 =   1; G3 = 0; Y3 =   0;

         r4 =   1; G4 =   0; Y4 =   0;

         SuperDelay () ;

         G1 =   0; Y1 =   1;

         Delay ( ) ;

         R1 =   1; G1 =   0; Y1 =   0;

         R2 =   0; G2 =   1; Y2 =   0;

         R3 =   1; G3 =   0; Y3 =   0;

         r4 =   1; G4 =   0; Y4 =   0;

        SuperDelay ( ) ;

         G2 =   0; Y2 =   1;

         Delay ( ) ;

         R1 =   1; G1 =   0; Y1 =   0;

         R2 =   1; G2 =   0; Y2 =   0;

         R3 =   0; G3 =   1; Y3 =   0;

         r4 =   1; G4 =   0; Y4 =   0;

SuperDelay ( ) ;

         G3 =   0; Y3 =   1;

         Delay();

         R1 =   1; G1 =   0; Y1 =   0;

         R2 =   1; G2 =   0; Y2 =   0;

         R3 =   1; G3 =   0; Y3 =   0;

         r4 =   0; G4 =   1; Y4 =   0;      

SuperDelay ( ) ;

         G4 =   0; Y4 =   1;

         Delay ( ) ;     

            

}

}

 The figure below shows the intersection of a main highway with secondary axes road. Vehicle detections sensors are placed along lanes C and D (main road) and l
 The figure below shows the intersection of a main highway with secondary axes road. Vehicle detections sensors are placed along lanes C and D (main road) and l

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site