您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 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;}}
本文标题:74hc595驱动8位数码管程序
链接地址:https://www.777doc.com/doc-5635783 .html