控制数码管循环显示单个数字,仿真加程序
单片机源程序如下:
- #include"reg51.h"
- #include"intrins.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define out P0
- uchar code seg[]={0xc0,0xa4,0x99,0x82,0x80,0xf9,0xb0,0x92,0xf8,0x90,0x01};
- void delayms(uint);
- void main(void)
- {
- uchar i;
- while(1)
- {out=seg[i];
- delayms(900);
- i++;
- if(seg[i]==0x01)i=0;
- }
- }
- void delayms(uint j)
- {
- uchar a;
- for(;j>0;j--)
- {
- a=250;
- while(--a);
- a=249;
- while(--a);
- }
- }
2020-6-19 16:46 上传
点击文件名下载附件
控制数码管循环显示单个数字