资源描述:
《用两个74HC164驱动两个四位的数码管.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、用两个74HC164驱动两个四位的数码管~~(一个简易电子钟)几天前我发一了帖寻求用两74HC164做动态扫描数码管~~~今天我折腾了一天终于把它难弄出来了~~~~~~其电路图是在一本书上找到的~~由于还没学会用protel99画图,,所以就只有将就一下了我的程序如下:#includesbitDAT=P1^1;sbitCLK=P1^2;unsignedcharcodetab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};//显示0~9unsignedcharcodeff[]
2、={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x77};//位选;unsignedchara,b,c,d,e,f,ch,hour,minite,second;//开启计时voidloading(){TMOD=0x22;TR0=1;ET0=1;EA=1;}以下是显示程序,共八个,因为有八个数码管;voidsendbyte(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xfe;
3、for(c=0;c<8;c++){CLK=0;DAT=num;CLK=1;num<<=1;}}voidsendbyte_1(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xfd;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}voidsendbyte_2(unsignedcharbyte){unsignedcharnum,c;num=tab[byt
4、e];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xfb;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}voidsendbyte_3(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xf7;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<
5、<=1;}}voidsendbyte_4(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xef;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}voidsendbyte_5(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CL
6、K=1;num<<=1;}num=0xdf;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}voidsendbyte_6(unsignedcharbyte){unsignedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0xbf;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}voidsendbyte_7(unsignedcharbyte){un
7、signedcharnum,c;num=tab[byte];for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}num=0x7f;for(c=0;c<8;c++){CLK=0;DAT=num&0x80;CLK=1;num<<=1;}}//延时~~voiddelay(){unsignedintj;for(j=0;j<250;j++);}main(){loading();while(1){a=hour/10;b=hour%10;c=minite/10;d=minite%10;e=second/10;f=second%