求修改一个C51单片机程序,外部中断开始8盏灯全亮,K1按下中断使数码管显示,K2按下LCD一二行显示

#include"reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
#define led P2
#define LCD1602_DATAPINS P0
sbit LCD1602_E=P2^7;
sbit LCD1602_RW=P2^5;
sbit LCD1602_RS=P2^6;

sbit k1=P3^2;
sbit k2=P3^3;

sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 Disp1[]="abc";
u8 Disp2[]="20000722";
u8 code smgduan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

void delay(u16 t)
{
while(t--);
}

void Lcd1602_Delay1ms(u16 c)
{
u8 a,b;
for (; c>0; c--)
{
for (b=199;b>0;b--)
{
for(a=1;a>0;a--);
}
}

}

void LcdWriteCom(u8 com)
{
LCD1602_E = 0;
LCD1602_RS = 0;
LCD1602_RW = 0;

LCD1602_DATAPINS = com;
Lcd1602_Delay1ms(1);

LCD1602_E = 1;
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}

void LcdWriteData(u8 dat)
{
LCD1602_E = 0;
LCD1602_RS = 1;
LCD1602_RW = 0;

LCD1602_DATAPINS = dat;
Lcd1602_Delay1ms(1);

LCD1602_E = 1;
Lcd1602_Delay1ms(5);
LCD1602_E = 0;
}

void LcdInit()
{
LcdWriteCom(0x38);
LcdWriteCom(0x0c);
LcdWriteCom(0x06);
LcdWriteCom(0x01);
LcdWriteCom(0x80);
}

void main()
{
u8 j;
LcdInit();
while(1)
{
EA=1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
PX0=1;
PX1=0;
for(j=0;j<8;j++)
{
delay(1000);
led=0;
}

}

}

void Int0()interrupt 0
{
for(;;)
{
if(k1==0)
{
delay(1000);
if(k1==0)
{
LSA=1;LSB=1;LSC=1;P0=smgduan[1];
LSA=0;LSB=1;LSC=1;P0=smgduan[8];
LSA=1;LSB=0;LSC=1;P0=smgduan[0];
LSA=0;LSB=0;LSC=1;P0=smgduan[3];
LSA=1;LSB=1;LSC=0;P0=smgduan[0];
LSA=0;LSB=1;LSC=0;P0=smgduan[5];
LSA=1;LSB=0;LSC=0;P0=smgduan[0];
LSA=0;LSB=0;LSC=0;P0=smgduan[9];
}
while(!k1);
}
}
}
void Int1()interrupt 2
{
u8 i;
for(;;)
{
if(k2==0)
{
delay(1000);
if(k2==0)
{
for(i=0;i<3;i++)
{
LcdWriteData(Disp1[i]);
}
LcdWriteCom(0x40+0x80);
for(i=0;i<10;i++)
{
LcdWriteData(Disp2[i]);
}

}
while(!k2);
}
}
}

第1个回答  2019-03-09
《西游记》(2011年,通称张版西游记,张纪中制片,张建业导演,吴樾、聂远、臧金生、徐锦江等主演)
第2个回答  2019-06-25
你是出现了什么问题呢,只给个程序没办法解答呀