51单片机按键控制数码管程序
摘要:#include<>#defineuintunsignedint#defineucharunsignedcharucharc;sbitp10=P1^0;sbitp11=P1^1;sbitp12=P1^2;sbitp13=P1^3;sbitp14=P1^4;sbitp15=P1^5;sbitp16=P1^6;sbitp17=P1^7;voiddelay(uintz);intb[]={0,1,2,3,4,5,6,7};//设置每一位显示的数字unsignedcharcodeTab[]={0xc0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};//共阳极数码管inta[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};voidmain(){EA=1;EX0=1;IT0=1;P1=0xff;while(1){for(c=0;c<8;c++)//数码管扫描显示{P2=a[c];P0=Tab[b[c]];delay(1);}}}voiddelay(uintz){uinta,b;for(a=z;a>0;a--)for(b=110;b>0;b--);}int_0()interrupt0{EA=0;if(p10==0)if(p11==0)if(p12==0)if(p13==0)if(p14==0)if(p15==0)if(p16==0)if(p17==0)EA=1;b[0]=(b[0]+1)%10;b[1]=(b[1]+1)%1
温馨提示:当前文档最多只能预览
5 页,若文档总页数超出了
5 页,请下载原文档以浏览全部内容。
本文档由 匿名用户 于 2020-11-15 02:37:43上传分享