/********************************************************************************************LED点阵实验(流动显示123456789)**说明通过P0和P2作为点阵接口**要求学员掌握LED点阵的工作原理和各点阵脚的定义及接法,具体接线请参考接线说明**我们采用的LED点阵式是低功耗,在做实验时可以用单片机脚直接驱动*******************************************************************************************/#includeunsignedcharcodetab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};unsignedcharcodedigittab[73][8]={{0X00,0X00,0X00,0X00,0X08,0X00,0X00,0X00},//0{0X00,0X00,0X00,0X14,0X22,0X14,0X00,0X00},{0X00,0X00,0X3E,0X41,0X41,0X41,0X3E,0x00},{0X18,0X08,0X00,0X00,0X00,0X00,0X00,0X00},//1{0X08,0X18,0X08,0X00,0X00,0X00,0X00,0X00},{0X08,0X08,0X18,0X08,0X00,0X00,0X00,0X00},{0X08,0X08,0X08,0X18,0X08,0X00,0X00,0X00},{0X08,0X08,0X08,0X08,0X18,0X08,0X00,0X00},{0X1C,0X08,0X08,0X08,0X08,0X18,0X08,0X00},{0X00,0X00,0X00,0X21,0X7F,0X01,0X00,0X00},{0X00,0X00,0X10,0X10,0X10,0X10,0X10,0X00},//2{0X00,0X00,0XE0,0XA0,0XA0,0XA0,0X20,0X00},{0X00,0X00,0X38,0X28,0X28,0X28,0XC8,0X00},{0X00,0X00,0X4E,0X8A,0X8A,0X8A,0X72,0X00},{0X00,0X00,0X27,0X45,0X45,0X45,0X39,0X00},{0X00,0X00,0X00,0X1c,0X1c,0X1c,0X00,0X00},//{0X00,0X00,0X2e,0X28,0X3e,0X0a,0X3a,0X00},{0X00,0X4F,0X48,0X48,0X7F,0X09,0X09,0X79},{0X00,0X4F,0X48,0X48,0X7F,0X09,0X09,0X79},{0XFF,0XFF,0XD5,0XD5,0X0D5,0XC1,0Xff,0XFF},//hei3{0XFF,0XFF,0XD5,0X2D5,0XD5,0XC1,0Xff,0XFF},{0XFF,0XFF,0XD5,0XD5,0XD5,0XC1,0Xff,0XFF},{0X00,0X00,0X22,0X49,0X49,0X49,0X36,0X00},//liang3{0X08,0X10,0X20,0X40,0X00,0X00,0X00,0X00},//4{0X08,0X18,0X28,0X48,0X08,0X08,0X08,0X00},{0X08,0X18,0X28,0X48,0X7F,0X08,0X08,0X00},{0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00},//5{0X00,0X00,0X20,0X40,0X40,0X40,0X20,0X00},//6{0X00,0X00,0X30,0X40,0X40,0X00,0X00,0X00},{0X00,0X00,0X38,0X40,0X40,0X00,0X00,0X00},{0X00,0X00,0X3c,0X40,0X00,0X00,0X00,0X00},{0X00,0X00,0X3E,0X00,0X00,0X00,0X00,0X00},{0X00,0X00,0X1E,0X01,0X00,0X00,0X00,0X00},{0X00,0X00,0X0E,0X01,0X01,0X00,0X00,0X00},{0X00,0X00,0X06,0X01,0X01,0X01,0X00,0X00},{0X00,0X00,0X02,0X01,0X01,0X01,0X02,0X00},{0X00,0X00,0X00,0X01,0X01,0X01,0X06,0X00},{0X00,0X00,0X00,0X00,0X01,0X09,0X06,0X00},{0X00,0X00,0X00,0X00,0X08,0X09,0X06,0X00},{0X00,0X00,0X00,0X08,0X08,0X08,0X06,0X00},{0X00,0X00,0X00,0X08,0X08,0X09,0X06,0X00},{0X00,0X00,0X00,0X08,0X09,0X09,0X06,0X00},{0X00,0X00,0X00,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X02,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X06,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X0E,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X1E,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X3E,0X09,0X09,0X09,0X06,0X00},{0X00,0X00,0X3E,0X49,0X09,0X09,0X06,0X00},{0X00,0X00,0X3E,0X49,0X49,0X09,0X06,0X00},{0X00,0X00,0X3E,0X49,0X49,0X49,0X06,0X00},{0X00,0X00,0X3E,0X49,0X49,0X49,0X26,0X00},{0X00,0X00,0X00,0X40,0X00,0X4A,0X20,0X00},//7{0X00,0X00,0X40,0X00,0X40,0X05,0X50,0X00},{0X00,0X00,0X40,0X40,0X40,0X4F,0X70,0X00},{0X00,0X06,0X6F,0XFF,0XFF,0X6F,0X06,0X00},//8{0X00,0X06,0X6F,0XBF,0XBF,0X6F,0X06,0X00},{0X00,0X06,0X6F,0X9f,0X9f,0X6F,0X06,0X00},{0X00,0X06,0X6F,0X97,0X97,0X6F,0X06,0X00},{0X00,0X06,0X6B,0X93,0X93,0X6B,0X06,0X00},{0X00,0X06,0X69,0X91,0X91,0X69,0X06,0X00},{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00},//9{0x30,0x48,0x88,0x90,0x62,0x22,0x14,0x08},//zuoshang9{0x00,0x38,0x44,0x44,0x78,0x40,0x44,0x38},//zuo9{0x0c,0x12,0x31,0x49,0x46,0x40,0x30,0x00},//zuoxia9{0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00},//dao9{0x30,0x48,0x84,0x8e,0x11,0x21,0x22,0x1c},//youxia9{0x1c,0x22,0x02,0x1e,0x22,0x22,0x1c,0x00},//you9{0x00,0x1c,0x02,0x61,0x92,0x8c,0x48,0x30},//youshang9{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00},//9{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00},//9};unsignedinttimecount;unsignedcharcnta;unsignedcharcntb;voidmain(void){TMOD=0x01;TH0=(65536-3000)/256;TL0=(65536-3000)%256;TR0=1;//开启定时0ET0=1;EA=1;//开启中断cntb=0;while(1){;}}/***************************************************定时中断********************************************************/voidt0(void)interrupt1using0{TH0=(65536-3000)/256;//定时器高位装载数据TL0=(65536-3000)%256;//定时器低位装载数据if(cnta<73)//红色{P1=0xFF;P2=tab[cntb];P0=digittab[cnta][cntb];}else//绿色{P2=0xFF;P1=tab[cntb];P0=digittab[cnta-73][cntb];}if(++cntb>=8)cntb=0;if(++timecount>=200){timecount=0;if(++cnta>=146)cnta=0;}}