#include<reg51.h>
sbit beiR=P1^0;
sbit beiY=P1^1;
sbit beiG=P1^2;
sbit nanR=P1^3;
sbit nanY=P1^4;
sbit nanG=P1^5;
uint a,b,c,type,j,i;
void Delay(uint x)
{
uchar i;
while(x--)for(i=0;i<120;i++);
}
void delay_ms(uint q)
{
uint i,j;
for(i=q;i>0;i--)
for(j=141;j>0;j--);
}
void shumaguan(uint k)
{
b=k/10;
c=k%10;
P3=11111101;
P2=smg_dw[b];
delay_ms(20);
P3=11111110;
P2=smg_dw[c];
delay_ms(20);
}
main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EX0=1;
EA=1;
IT0=1;
a=10;
type=1;
while(1){
switch(type)
{
case 1:
beiR=0;beiY=1;beiG=1;
nanR=1;nanY=1;nanG=0;
shumaguan(a);
break;
case 2:
if(a%2!=0)
{
beiR=1;beiY=0;beiG=1;
}
if(a%2==0)
{
beiR=1;beiY=1;beiG=1;
}
shumaguan(a);
break;
case 3:
beiR=1;beiY=1;beiG=0;
nanR=0;nanY=1;nanG=1;
shumaguan(a);
break;
case 4:
if(a%2!=0)
{
nanR=1;nanY=0;nanG=1;
}
if(a%2==0)
{
nanR=1;nanY=1;nanG=1;
}
shumaguan(a);
break;
}
}
}
|