【51单片机实现0-7和8-1循环显示共阴数码管】2023-5-12
____simple_html_dom__voku__html_wrapper____>
缘由https://ask.csdn.net/questions/7942557
#include "reg52.h"
unsigned char code ShuMaGuan[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00,0X80,64};//0~9隐.小数点-号
void main()
{
unsigned char w=0,x=8,ys=0,sy=0;
bit k=0;
while(1)
if(++ys==0)
{
P0=P1=255;
if(!w)++w;
P1=~w;
w*=2;
P0=ShuMaGuan[x-1];
--x;
if(!x)x=8;
}
}
把之上基本的演化为自动循环的,数码管驱动编写原则是:消隐、送位值、送段值、延时。
#include "reg52.h"
unsigned char code ShuMaGuan[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00,0X80,64};//0~9隐.小数点-号
void main()
{//缘由https://ask.csdn.net/questions/7942557
unsigned char w=0,x=8,ys=0,sy=0,m=0;
bit k=0;
while(1)
if(++ys==0)
{
P0=P1=255;
if(!w)++w;
P1=~w;
w*=2;
P0=ShuMaGuan[k?x:x-1];
if(!k)--x;else ++x;
if(!k)if(!x)x=8;else;else if(x>8)x=1;else;
if(++sy==0)if(++m>7){m=0;k=!k;if(k)x=1;else x=8;}
}
}


坚决捍卫人类平安,严惩自招暴力肇事。
© 版权声明
文章版权归作者所有,未经允许请勿转载。