您的位置 首页 芯闻

单片机操控的计数简略程序

includereg51h>unsignedcharc,i,k,p;sbitp10=P1^0;unsignedchars[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7

#include
unsigned char c,i,k,p;
sbit p10=P1^0;
unsigned char s[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
main()

{unsigned char key1,key2;
unsigned char i,k;
void delay();
void delay2();
unsigned char getkey();
while(1){
delay2();//消除程序履行太快 引起的屡次判别

key1=0;key2=0;
key1=getkey();
if(key1==0) continue;//没有键按下 持续循环检测
delay();
key2=getkey();
if(key1==key2) {P2=s[i];P3=s[k];k++;if(k==10) {k=0;i++;if(i==10)i=0;}} }}

void delay()
{unsigned char a,b;
for(a=20;a>0;a–)
for(b=248;b>0;b–)
{}
}
unsigned char getkey()
{if(p10==0) {return 1;}
else return 0;}
void delay2()
{unsigned char a,b,c;
for(c=20;c>0;c–)
for(a=20;a>0;a–)
for(b=248;b>0;b–)
{}}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/news/xinwen/260928.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部