HOLTEK單片機(jī)-數(shù)碼管顯示
程序:
#include "HT48F50E.H"const unsigned char number[16]={0x81,0xcf,0x92,0x86,0xcc,0xa4,0xa0,0x8f,0x80,0x84,0x88,0xe0,0xb1,0xc2,0xb0,0xb8}; //數(shù)碼管顯示0-Fvoid delayms(unsigned int dly){unsigned int i;for(i=0;idly;i++){_delay(984);} } //延時(shí)函數(shù)1MSvoid main(){ unsigned char j;_pac=0x00;_pbc=0x00; //PA,PC輸出選擇while(1) //大循環(huán){ for(j=0;j50;j++) //循環(huán)顯示{_pb=0xfe; //選通第一位數(shù)碼管_pa=number[0]; //顯示0delayms(5); //延時(shí)5MS(下同)_pb=0xfd;_pa=number[1];delayms(5);_pb=0xfb;_pa=number[2];delayms(5);_pb=0xf7;_ pa=number[3];delayms(5);}for(j=0;j50;j++){_pb=0xfe;_pa=number[4];delayms(5);_pb=0xfd;_pa=number[5];delayms(5);_pb=0xfb;_pa=number[6];delayms(5);_pb=0xf7;_pa=number[7];delayms(5);}for(j=0;j50;j++){_pb=0xfe;_pa=number[8];delayms(5);_pb=0xfd;_pa=number[9];delayms(5);_pb=0xfb;_pa=number[10];delayms(5);_pb=0xf7;_pa=number[11];delayms(5);} for(j=0;j50;j++){_pb=0xfe;_pa=number[12];delayms(5);_pb=0xfd;_pa=number[13];delayms(5);_pb=0xfb;_pa=number[14];delayms(5);_pb=0xf7;_pa=number[15];delayms(5);}}}
評(píng)論