#include<reg51.h>
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
uchar Tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
uchar nt=10,wt=10,sz=0,t,DJS=10,seg=10,tx=5;
bit ms=0;sbit k = P3^0;
sbit we1=P0^0;
sbit we2=P0^1;
sbit NSG=P1^5;
sbit NSY=P1^4;
sbit NSR=P1^3;
sbit WEG=P1^2;
sbit WEY=P1^1;
sbit WER=P1^0;
void delay(uint t);
void display();
void Init_Timer0(void);
void NST();
void WET();
void jstx();void delay(uint t)
{
uchar x,y;
for(x=0;x<t;x++)
for(y=0;y<200;y++);
}void main()
{
Init_Timer0();
while(1)
{ if(sz==0)
{
if(ms==0)
{NST();}
if(ms==1)
{WET();}
}display();
}
}void display()
{
we1=0;
we2=1;
P2=Tab[seg/10];
delay(5);
P2=0x00;
we1=1;
we2=0;
P2=Tab[seg%10];
delay(5);
P2=0x00;
}
void Init_Timer0(void)
{
TMOD= 0x01;
TH0=0x3c;
TL0=0xb0;
IP=0x02;
TR0=1;
ET0=1;
EA=1;
}
void timer0 (void) interrupt 1
{
TH0=0x3c;
TL0=0xb0;
t++;
if(t==20)
{
DJS--;
t=0;
if(seg==0&&sz%2==0)
{
seg=5;
sz++;
}
else if(seg==0&&sz%2==1)
{
seg=10;
sz++;
}
switch(sz%2)
{
case 0:
NSG=0;
NSR=1;
NSY=1;
WER=0;
WEG=1;
WEY=1;
break;
case 1:
NSG=1;
NSR=1;
NSY=0;
WER=0;
WEG=1;
WEY=1;
break;
case 2:
NSG=1;
NSR=0;
NSY=1;
WER=1;
WEG=0;
WEY=1;
break;
case 3:
NSG=1;
NSR=0;
NSY=1;
WER=1;
WEG=1;
WEY=0;
break;
}void WET()
{
seg=DJS;
NSG=1;
NSR=0;
NSY=1;
WER=1;
WEG=0;
WEY=1;
}void NST()
{
seg=DJS;
NSG=0;
NSR=1;
NSY=1;
WER=0;
WEG=1;
WEY=1;
|