#include<reg52.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int uchar code table[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uchar code LED_W[8] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; uchar temp,tt; char num; void main() { TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; tt=0; num=0; temp=0xfe; P1=temp; P2=LED_W[num]; P0=table[num]; while(1) { if(tt==20) { tt=0; temp=_crol_(temp,1); P1=temp; if(num==7) num=-1; P2=LED_W[++num]; P0=table[num]; } } } void time() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; tt++; }