Programming with C language to simulate the control function of traffic lights at traffic intersections (intersections)

The design of this system should first understand the lighting and extinguishing rules of traffic street lamps. There is a crossroads, 1 and 3 are south or north.

Direction, 2 and 4 are east and west, and the initial state is that the red lights at four intersections are all on. After that, the green light at 1 and 3 intersections is on.

The red light at intersections 2 and 4 is on, and the direction of intersections 1 and 3 is open to traffic. After a time delay, the green light at 1 and 3 intersections goes out, while 1,

The yellow light at the intersection began to blink. After several flashes, the red light at 1 and 3 intersections is on, and the green light at 2 and 4 intersections is on.

The direction of intersection 4 is open to traffic. After a delay, the green lights at intersections 2 and 4 went out and the yellow lights began to flash. Blinking if

After finishing the time, switch to the intersection direction of 1 and 3. After that, the above process is repeated. For each set of lights on and off, we use

It is the input and output function of 8255A.