ݷʱ : 2024/11/9 9:49:53һ µȫĶ
N T0Ӧ 0.5s Y ϱƵƱ־λΪ1 N ƵƱ־λΪ1 N N 1s Y ʱ1,ֵ0 Y Ƶλ÷ Y ϱƵλ÷ ͼ3.2 ʱ0жͼ
2.
#include
/*************˿ڶ*************/
sbit EW_ShuMa2=P2^3; //EWλܿλ sbit EW_ShuMa1=P2^2; //EWλܿλ sbit SN_ShuMa2=P2^1; //SNλܿλ sbit SN_ShuMa1=P2^0; //SNλܿλ
sbit SN_Yellow=P1^1; //SNƵ
sbit EW_Yellow=P1^5; //EWƵ
sbit EW_ManGreen=P2^7; //EWе̵ sbit SN_ManGreen=P2^4; //SNе̵ sbit EW_ManRed=P2^6; //EWе sbit SN_ManRed=P2^5; //SNе sbit EW_Red=P1^6; //EWֱе sbit SN_Red=P1^2; //SNֱе
sbit shezhi1=P3^0; //ģʽü
sbit shezhi2=P3^1; //ģʽü sbit stop1=P3^7; //
bit Flag_SN_Yellow; //SNƵƱ־λ bit Flag_EW_Yellow; //EWƵƱ־λ
char Time_EW; //ʱԪ char Time_SN; //ϱʱԪ
uchar EW=30,SN=20,EWL=9,SNL=9; //ʼֵģʽ uchar EW1=30,SN1=20,EWL1=9,SNL1=9;
uchar code table[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; //0-9ѡ
uchar code State[8]={0xBE,0xBD,0xB7,0xBD,0xEB,0xDB,0x7B,0xDB}; /****************************/ void Delay_ms(uint z); void ShuMa_Display(); void timer0_init(); void state1(); void state2();
void state3(); void state4();
/**************************/ void main() {
timer0_init(); //ʱʼ EW1=read(10); //24c02 SN1=read(11); EWL1=read(12);
SNL1=read(13); EW=EW1; SN=SN1; EWL=EWL1; SNL=SNL1; //Int_init(); while(1) { state1();
state2();
state3(); state4(); } }
/*************ʱ*************/ /*void Delay_ms(uint z) { uint x,y;
for(x=120;x>0;x--) for(y=z;y>0;y--);
}*/
/**************ʾ*****************/ void ShuMa_Display() {
uchar H,L;
H=Time_EW/10; L=Time_EW;
P0=table[L];
EW_ShuMa2=0; //EW_LED2
Delay_ms(1);
EW_ShuMa2=1; //ϨEW_LED2 P0=table[H];
EW_ShuMa1=0; //EW_LED1 Delay_ms(1); EW_ShuMa1=1; H=Time_SN/10; L=Time_SN;
P0=table[L];
SN_ShuMa2=0; //SN_LED2 Delay_ms(1); SN_ShuMa2=1; P0=table[H]; SN_ShuMa1=0; //SN_LED1 Delay_ms(1); SN_ShuMa1=1;
}
/***************ģʽ****************/ void state1() {
/*********SNͨSWֹ*********/ SN_ManRed=1; SN_ManGreen=0; //SNеͨ EW_ManRed=0; //EWеֹ EW_ManGreen=1; Flag_SN_Yellow=0; //SNػƵʾź Flag_EW_Yellow=0; //EWػƵʾź
Time_EW=EW; Time_SN=SN;
while(Time_SN>=5) {
P1=State[0]; //SN̵ƣEW ShuMa_Display(); }
P1=0xff;//رP1е while(Time_SN>=0) {
Flag_SN_Yellow=1; //SNƵźλ EW_Red=0; //P1=P1 |0XB0; //EW ShuMa_Display(); } }
void state2() { /************SN״̬**********/
SN_ManRed=0; //SNеֹ SN_ManGreen=1;
EW_ManRed=0; //EWеֹ EW_ManGreen=1;
Flag_SN_Yellow=0; //SNػƵʾź Flag_EW_Yellow=0; //EWػƵʾź Time_SN=SNL; Time_EW=EWL; while(Time_SN>=5)