|
只寫了部分關(guān)鍵代碼,其他代碼略。
unsigned char num;//定義一個變量
unsigned char code table[]={//共陽數(shù)碼管段碼"0~f"
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
num=SBUF; //串口接收到的一個字節(jié)數(shù)據(jù)
Px=table[num&0x0f];//顯示低4位(Px為數(shù)碼管段碼端口)
Px=table[num>>4&0x0f];//顯示高4位
|
|