微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > LCD12232串行显示C51程序

LCD12232串行显示C51程序

时间:11-29 来源:互联网 点击:

while(1)
{
key_code=s_scan();
//------------------------------------------------------
//键值处理程序,包含数字输入键和字母输入键以及功能键操作
//------------------------------------------------------
switch(key_code)
{
case 1:
{
Lcd_Wr_Data(1);
Delay_ms(300);
}break;
case 2:
{
Lcd_Wr_Data(2);
Delay_ms(300);
}break;
case 3:
{
Lcd_Wr_Data(3);
Delay_ms(300);
}break;
case 4:
{
Lcd_Wr_Data(4);
Delay_ms(300);
}break;
case 5:
{
Lcd_Wr_Data(5);
Delay_ms(300);
}break;
case 6:
{
Lcd_Wr_Data(6);
Delay_ms(300);
}break;
case 7:
{
Lcd_Wr_Data(7);
Delay_ms(300);
}break;
case 8:
{
Lcd_Wr_Data(8);
Delay_ms(300);
}break;
case 9:
{
Lcd_Wr_Data(9);
Delay_ms(300);
}break;
case 10:
{
Lcd_Wr_Data(0);
Delay_ms(300);
}break;
case 11:
{
Posit(5,2,"CD");
Delay_ms(300);

}break;
case 12:
{
Posit(5,2,"LS");
Delay_ms(300);
}break;

case 13:
{
P3=0x00;
if(Key_Select==1) //CMOS芯片型号CD4053
{

}
if(Key_Select==2) //TTL 芯片型号74LS00
{
P3=0x00;
P1=0x00;
B4=0x00;

B6=0;B7=0;
B3=0;B4=0;

if((A0&0x01)&&(A3&0x01)&&(B0&0x01)&&(B5&0x01))
{
Buz();
Buz();Delay_ms(500);
Lcd_Wr_Command(0x01);
Posit(0,1,"测试结果:");
Posit(4,2,"OK!");
Buz();Delay_ms(100);
Buz();Delay_ms(300);
Buz();Delay_ms(500);
Buz();Delay_ms(800);
Buz();Delay_ms(1000);
Buz();Delay_ms(800);
Buz();Delay_ms(500);
Buz();Delay_ms(300);
Buz();Delay_ms(100);
}
else
{
Buz();
Lcd_Wr_Command(0x01);
Posit(0,1,"测试结果:");
Posit(4,2,"FAIL!");
while(Key_Select)
{
Buz();
}
}
}
Delay_ms(300);
} break;

case 14: //选择键
{
Key_Select++;
if(Key_Select==1)
{
Lcd_Wr_Command(0x0f);
Lcd_Wr_Command(0x90);
}
if(Key_Select==2)
{
Lcd_Wr_Command(0x0f);
Lcd_Wr_Command(0x94);
}
if(Key_Select==3)
{
Lcd_Wr_Command(0x0c);
Key_Select=0;
}
Delay_ms(300);
}break;
case 15: //确认键
{
Key_Mode++;
if(Key_Mode==3)
{
Key_Mode=0;
Key_Select=0;
Lcd_Wr_Command(0x0c);
Lcd_Wr_Command(0x01);
Lcd_Wr_Command(0x02);
Posit(0,1,Disp_7);
Posit(0,2,Disp_8);
}
if(Key_Mode==1)
{
Lcd_Wr_Command(0x01);
Posit(0,1,Disp_9);
Posit(0,2,Disp_10);
}
if(Key_Mode==2)
{
if(Key_Select==1)
{
Lcd_Wr_Command(0x01);
Lcd_Wr_Command(0x02);
Posit(0,1,Disp_11);
Posit(0,2,Disp_13);
//Lcd_Wr_Command(0x95);
}
if(Key_Select==2)
{
Lcd_Wr_Command(0x01);
Lcd_Wr_Command(0x02);
Posit(0,1,Disp_12);
Posit(0,2,Disp_13);
//Lcd_Wr_Command(0x95);
}
}
Delay_ms(300);
}break;
case 16: //取消键
{
if(Key_Select==1)
{
Lcd_Wr_Command(0x0c);
Lcd_Wr_Command(0x01);
Lcd_Wr_Command(0x02);
Lcd_Wr_Command(0x0f);
Posit(0,1,Disp_11);
Posit(0,2,Disp_13);
//Lcd_Wr_Command(0x95);
}
if(Key_Select==2)
{
Lcd_Wr_Command(0x0c);
Lcd_Wr_Command(0x01);
Lcd_Wr_Command(0x02);
Lcd_Wr_Command(0x0f);
Posit(0,1,Disp_12);
Posit(0,2,Disp_13);
//Lcd_Wr_Command(0x95);
}
Delay_ms(300);
}break;

default:P0=0xff;
}
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top