#include <AT89X52.H> #include "74HC595.H" unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; unsigned char code digittab[10][8]={ //字模取模方式 陰碼 逆向 逐列式 {0x00,0x00,0x3E,0x41,0x41,0x3E,0x00,0x00},/*"0",0*/ {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},/*"1",1*/ {0x00,0x00,0x62,0x51,0x49,0x46,0x00,0x00},/*"2",2*/ {0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00},/*"3",3*/ {0x00,0x00,0x38,0x26,0x7F,0x20,0x00,0x00},/*"4",4*/ {0x00,0x00,0x4F,0x49,0x49,0x31,0x00,0x00},/*"5",5*/ {0x00,0x00,0x3E,0x49,0x49,0x32,0x00,0x00},/*"6",6*/ {0x00,0x00,0x03,0x71,0x09,0x07,0x00,0x00},/*"7",7*/ {0x00,0x00,0x36,0x49,0x49,0x36,0x00,0x00},/*"8",8*/ {0x00,0x00,0x26,0x49,0x49,0x3E,0x00,0x00},/*"9",9*/ }; unsigned int timecount; unsigned char cnta; unsigned char cntb; void main(void) { TMOD=0x01; TH0=(65536-1000)/256; TL0=(65536-1000)%256; TR0=1; ET0=1; EA=1; while(1); } void t0(void) interrupt 1 using 0 { TH0=(65536-1000)/256; TL0=(65536-1000)%256; Ser_IN(tab[cnta]);//8X8點陣列掃描 Ser_IN(digittab[cntb][cnta]);//8X8點陣行送掃描數據 Par_OUT();//74HC595輸出顯示 cnta++; if(cnta==8) { cnta=0; } timecount++; if(timecount==1000) { timecount=0; cntb++; if(cntb==10) { cntb=0; } } } |