Red de conocimiento informático - Conocimiento sistemático - Por favor, ayúdenme con la programación en lenguaje C para semáforos en cruces. ¡Urgente! ! !

Por favor, ayúdenme con la programación en lenguaje C para semáforos en cruces. ¡Urgente! ! !

#include

#define uchar unsigned char

#define uint unsigned int

sbit RED_A = P0^ 0;

bit AMARILLO_A = P0^1;

bit VERDE_A = P0^2;

bit RED_B = P0^3;

sbit YELLOW_B = P0^4;

sbit GREEN_B = P0^5;

uchar Flash_Count = 0, Operation_Type=1;

void DelayMS(uint x )

{

uchar i;

while (x--) for (i=0;i<120;i++);

}

void Traffic_Light()

{

interruptor (Operation_Type)

{

caso 1 :

RED_A=1;YELLOW_A=1;GREEN_A=0;

RED_B=0;YELLOW_B=1;GREEN_B=1;

RetrasoMS(2000) ;

Operation_Type=2;

pausa;

caso 2:

DelayMS(300);

YELLOW_A=!YELLOW_A;GREEN_A=1;

if(++Flash_Count!=10) return;

Flash_Count=0;

Operation_Type=3;

ruptura;

caso 3:

RED_A=0;YELLOW_A=1;GREEN_A=1;

RED_B=1;YELLOW_B= 1;GREEN_B=0;

DelayMS(2000);

Operation_Type=4;

pausa;

caso 4:

DelayMS(300);

YELLOW_B=!YELLOW_B;GREEN_B=1;

if(++Flash_Count!=10) return;

Flash_Count=0;

Operation_Type=1;

break;

}

}

void main ()

{

mientras(1) Traffic_Light();

}