【51单片机数码管的控制开机时前四位数码管显示0000,每按下一次按键后松开数字加121,当数字大于等于8888时清零。】2022-3-18
#include "REG52.h"
sbit K1 = P3^1;
unsigned char code SmZiFu[]={63,6,91,79,102,109,125,7,127,111,128,119,124,57,94,121,113};//0-9.
void smxs(unsigned char mz, unsigned char w)
{
unsigned char Xd=0;
P2=255;
P2=255-SmZiFu[mz];
P0=w;
while(++Xd);
}
void main()
{
unsigned char Xd=0,ss=1,cs=0,d=0,y=0;
unsigned int ys=0;
while(1)
{
smxs(ys/1000,1);
smxs(ys/100%10,2);
smxs(ys/10%10,4);
smxs(ys%10,8);
if(K1==0&&++Xd==0){ while(++Xd==0);ys+=121; }
if(ys>=8888)ys=0;
}
}
原文地址:https://blog.csdn.net/xianfajushi/article/details/123585667
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!