正文

数码管动态显示2007-11-07 12:45:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/yanyoushuai/30801.html

分享到:

#include <reg51.h>typedef unsigned char byte;// 0-255 typedef unsigned char word;//0-65535static byte arry_display[5];byte table[10]={0x42,0xee,0x58,0x68,0xe4,0x61,0x41,0xea,0x40,0x60};//0-9//显示函数void display(void){byte position=0xfe;byte i,j,temp;for(i=0;i<4;i++)//4数码管轮留导通 { temp=arry_display[i]; temp=table[temp]; for(j=0;j<200;j++)//延时  {  P2=position;P0=temp;  } position<<=1; position|=0x01;//以保证循环点亮  }//position=0xfe;}///将10进制转化为BCD int cov_bcd(unsigned int n){ arry_display[0]=n/1000;//千位 arry_display[1]=(n/100)%10;//百位 arry_display[2]=(n/10)%10;//十位 arry_display[3]=n%10; //个位}void main(void){unsigned int a;a=0x00;   while(1) { for(;a<9999;a++)  {  cov_bcd(a);  display();  //for(j=0;j<3000;j++);  }    a=0x00; }}

阅读(1998) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册