完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
一、基础理解
1、基础介绍
3、C51程序 #include #define duanxuan P1 //段选接口 #define weixuan P2 //位选接口 unsigned char code wxcode[4]={0xfe,0xfd,0xfb,0xf7}; unsigned char code dxcode[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; void DigDisplay(int num); void main() { int num = 9876; int t = 0; //每隔一段时间num-1 while(1) { t++; if(t == 500) t = 0, num--; DigDisplay(num); } } //num是显示的数字 void DigDisplay(int num) { unsigned char i; unsigned int j; int gewei,shiwei,baiwei,qianwei; gewei = num % 10; shiwei = num / 10 % 10; baiwei = num / 100 % 10; qianwei = num / 1000; for(i=0; i<4; i++) { weixuan = wxcode; duanxuan = 0xff; if(i == 3) { duanxuan = dxcode[gewei]; } if(i == 2) { duanxuan = dxcode[shiwei]; } if(i == 1) { duanxuan = dxcode[baiwei]; } if(i == 0) { duanxuan = dxcode[qianwei]; } j=10; while(j--); duanxuan=0xff; } } 三、共阴极数码管 1、基础介绍
3、C51程序代码 #include #define duanxuan P1 #define weixuan P2 unsigned char code wxcode[4]={0xfe,0xfd,0xfb,0xf7}; unsigned char code dxcode[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; void DigDisplay(int num); void main() { int num = 9876; int t = 0; while(1) { t++; if(t == 500) t = 0, num--; DigDisplay(num); } } void DigDisplay(int num) { unsigned char i; unsigned int j; int gewei,shiwei,baiwei,qianwei; gewei = num % 10; shiwei = num / 10 % 10; baiwei = num / 100 % 10; qianwei = num / 1000; for(i=0; i<4; i++) { weixuan = wxcode; duanxuan = 0x00; if(i == 3) { duanxuan = dxcode[gewei]; } if(i == 2) { duanxuan = dxcode[shiwei]; } if(i == 1) { duanxuan = dxcode[baiwei]; } if(i == 0) { duanxuan = dxcode[qianwei]; } j=10; while(j--); duanxuan=0x00; } } |
|
|
|
只有小组成员才能发言,加入小组>>
3263 浏览 9 评论
2944 浏览 16 评论
3443 浏览 1 评论
8955 浏览 16 评论
4036 浏览 18 评论
1079浏览 3评论
559浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
552浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2287浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1848浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 16:38 , Processed in 0.865264 second(s), Total 47, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号