#include "reg51.h" #define uchar unsigned char #define uint unsigned int uchar T0_count; uchar i; unsigned char light[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; void T0_int(void) interrupt 1 { TH0 = 0x4C; //重新装载,50MS定时器初值 TL0 = 0x00; T0_count++; if(T0_count==20) //1S到 { T0_count = 0; P1 = light[i]; i++; if (i>7) i = 0; } } main() { TMOD = 0x01;//定时器0,工作方式1,16位计数 TH0 = 0x4C; //50MS定时器初值 TL0 = 0x00; IE = 0x82; //开总中断,开T0中断 EA = 1; ET0 = 1; TR0 = 1; T0_count = 0; i = 0; loop: goto loop; }
求采纳
温馨提示:答案为网友推荐,仅供参考