# define uchar unsigned char# define uint unsigned int# include & lt; Reg52. H>/* * * * * defined control a * * * * * * * * * * * * * * * * * * * * * */sbit EW_LED2=P2 ^ 3;//EW_LED2 control bits sbit EW_LED1=P2 ^ 2;//EW_LED1 control bits sbit SN_LED2=P2 ^ 1;//SN_LED2 control bits sbit SN_LED1=P2 ^ 0;//SN_LED1 control bits sbit SN_Yellow=P1 ^ 6;//SN yellow light sbit SN_Red=P1 ^ 7;//SN red sbit EW_Yellow=p ^ 2;//EW yellow light sbit EW_Red=P1 ^ 3;//EW red bit Flag_SN_Yellow;//SN yellow marks a bit Flag_EW_Yellow;//EW yellow marks a char Time_EW;//what direction the countdown units char Time_SN; The north and south direction//countdown units uchar EW=10, SN=10, EWL=3, SNL=3;//program initialization assignment, normal mode uchar EW1=10, SN1=10, EWL1=3, SNL1=3;//to hold to modify the value of the variable uchar code table [10]={xa4 xc0 0, 0 xf9, 0, 0 xb0, 0 x99, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90};//0 ~ ~ ~ ~ 9 segment code uchar code S [9]={x18 x28 0, 0 x48, 0, 0 x48, 0 x82, 0 x84, 0 x81, 0 x84, 0 x88};//traffic light control code/* * * * * * * * * * * * * * * * * * * * * * delay subroutine * * * * * * * * * * * * * * * * * * * * * * * */void delay_ms (unsigned int x)//delay ms {unsigned int I, j; For (I=x; I> 0; I -) for (j=110; J> 0; j--); }/* * * * * * * * * * * * * * * * * according to child function * * * * * * * * * * * * * * * * * * * * * * * * * */void Display (void) {char h, l; H=Time_EW/10; L=Time_EW % 10; P0=table [l]; EW_LED2=1; Delay_ms (1); EW_LED2=0; P0=table [h]; EW_LED1=1; Delay_ms (1); EW_LED1=0; H=Time_SN/10; L=Time_SN % 10; P0=table [l]; SN_LED2=1; Delay_ms (1); SN_LED2=0; P0=table [h]; SN_LED1=1; Delay_ms (1); SN_LED1=0; }/* * * * * * * * * * * * * * * * * * * * * * T0 interrupt service routine * * * * * * * * * * * * * * * * * * */void timer0 (void) interrupt using 1 {static uchar count; TH0=(65536-50000)/256; TL0=(65536-50000) % 256; count++; If (count==10) {if (Flag_SN_Yellow==1)//test the yellow flag bit {SN_Yellow=~ SN_Yellow; } the if (Flag_EW_Yellow==1)//test something yellow flag bit {EW_Yellow=~ EW_Yellow; }} the if (20) count=={Time_EW -; Time_SN -; If (Flag_SN_Yellow==1)//test the yellow flag bit {SN_Yellow=~ SN_Yellow; } the if (Flag_EW_Yellow==1)//test something yellow flag bit {EW_Yellow=~ EW_Yellow; } count=0; }}/* * * * * * * * * * * * * * * * * * * * * the main program began to * * * * * * * * * * * * * * * * * * * * * */void main (void) {TMOD=0 x01;//timer in mode 1 TH0=(65536-50000)/256;//timer initialise TL0=(65536-50000) % 256; EA=1;//CPU interrupt always allow ET0=1;//timer interrupt TR0=1;//start time/* * * * * * * S0 state (initial state) * * * * * * * * * */Time_EW=3; Time_SN=3; While (Time_SN & gt;=0 | | Time_EW & gt;=0) {Flag_EW_Yellow=0;//EW turning yellow light signaling P1=S [8];//all the crossing the red light Display (); } the while (1) {/* * * * * * * S1 state (the main straight state) * * * * * * * * * */Time_EW=EW; Time_SN=SN; While (Time_SN & gt; 4)={Flag_EW_Yellow=0;//EW turning yellow light signaling P1=S [0];//SN and EW red light Display (); * * * * * * *}/S2 state (the main straight yellow lights flashing status) * * * * * * * * * */P1=0 x00; While (Time_SN & gt;=0) {Flag_SN_Yellow=1;//SN yellow light signal EW_Red=1;//SN yellow light, wait for a left turn signal and EW red light Display (); }/* * * * * * * * * * * assignment (main road traffic trunk road traffic) * * * * * * * * * */EW=EW1; SN=SN1; EWL=EWL1; SNL=SNL1;/* * * * * * * S3 state (the trunk road straight state) * * * * * * * * * */Time_EW=SN; Time_SN=EW; While (Time_EW & gt; 4)={Flag_SN_Yellow=0;//SN turning yellow light signaling P1=S [4];//EW and SN red light Display (); * * * * * * *}/S4 state (the trunk road straight yellow lights flashing status) * * * * * * * * * */P1=0 x00; While (Time_EW & gt;=0) {Flag_EW_Yellow=1;//EW yellow light signal SN_Red=1;//EW yellow light, wait for a left turn signal and SN red light Display (); }/* * * * * * * * * * * assignment (the trunk road traffic trunk road traffic) * * * * * * * * * */EW=EW1; SN=SN1; EWL=EWL1; SNL=SNL1; }}
, can you help to tell me what is going wrong, sincerely ask,
CodePudding user response:
Problem has been solve thank thank
CodePudding user response:
The building of digital tube display not all is how to solve
CodePudding user response:
Digital tube can be decoded with static drive, because the simulation non-food, scanning mode will display looks is not complete