74hc595驱动8位数码管程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

/********************************************************************************116*2012.sunmer*74HC5958*******************************************************************************/#includereg52.hsbitser=P1^0;sbitrck=P1^2;sbitsck=P1^1;unsignedcharseg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//unsignedcharno[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//unsignedcharnum[8]={2,0,1,2,0,7,1,3};//2012.07.13unsignedcharal;unsignedintadd;/***************************************************************************************************************************************************************//*t*/voiddelay_ms(unsignedintdelaytime){unsignedinti,j;for(i=0;idelaytime;i++)for(j=0;j125;j++);/*11.0592M1ms*/}/********************************************************************************595********************************************************************************/voidsend_595_data(unsignedcharsend_address,unsignedcharsend_data){unsignedchari,j,temp0,temp1;temp0=send_address;temp1=send_data;if((al==3)||(al==5))//{if(add300)temp1&=0x7f;}for(i=0;i8;i++)//{if(temp0&0x80)ser=1;elseser=0;temp0=1;rck=0;rck=1;}for(j=0;j8;j++)//{if(temp1&0x80)ser=1;elseser=0;temp1=1;rck=0;rck=1;}sck=0;sck=1;//sck=0;}/***************************************************************************************************************************************************************/voidmain(void){for(;;){for(al=0;al8;al++){send_595_data(~no[7-al],seg[num[al]]);//2012.07.13}add++;if(add==600)add=0;}}

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功