#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar bai,shi,ge,num;
sbit k1=P1^0;
sbit k2=P1^1;
sbit k3=P1^2;
uchar code table[]={
0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
void delay(uint z)
{ int x,y;
for(y=z;y>0;y--)
for(x=10;x>0;x--);
}
void key1();
void key2();
void key3();
void init();
void display(uchar bai,uchar shi,uchar ge);
void main()
{
P1=0x0f;
key1();
display(bai,shi,ge);
}
void key1()
{
if(k1==0)
{
delay(10);
if(k1==1)
{
num++;
bai=num/100;
shi=num%100/10;
ge=num/10;
}
}
}
void display(uchar bai,uchar shi,uchar ge)
{
while(k1&&k2&&k3==1)
{
P0=table[bai];
P2=0x80;
delay(10);
P0=table[shi];
P2=0x40;
delay(10);
P0=table[ge];
P2=0x20;
delay(10);
}
}
k1为加数按键,P2为段选
程序无法执行,按下按键后跳不出while循环~求高手帮助~谢谢谢谢~
此帖出自
小平头技术问答
起码有个WHILE(1)
{
....
}
结构的.
一周热门 更多>