【求大神帮我改写程序,使按键k2按下时,显示屏数字可以加1,以下是程序】
#include<reg51.h>#define uchar unsigned char
#define uint unsigned int
#define shuchu P0
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
sbit key_jia=P3^1;
void xiezhiling(uchar);
void xieshuju(uchar shuju);
char shuju;
void delay(uint);
void chushi();
void main()
{
chushi();
while(1)
{
xiezhiling(0x81);
xieshuju('0');
//delay(10000);
}
}
void chushi()
{
xiezhiling(0x38);
xiezhiling(0x01);
xiezhiling(0x0f);
xiezhiling(0x06);
}
void xiezhiling(uchar zhiling)
{
RS=0;
RW=0;
E=0;
shuchu=zhiling;
E=1;
delay(5);
E=0;
}
void xieshuju(uchar shuju)
{
RS=1;
RW=0;
E=0;
shuchu=shuju;
E=1;
delay(5);
E=0;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=123;y>0;y--);
}
|