#include "reg52.h" //此文件中定义了单片机的一些特殊功能寄存器
#include "lcd.h"
typedef unsigned char u8;
sbit k1=P1^0;
sbit jian1=P3^0; //按键
sbit jian2=P3^1; //按键
sbit jian4=P3^3; //按键
sbit yg1=P1^0; //箭头
unsigned char l=1,kkk=1,vv=1;
/*******************************************************************************
* 函 数 名 : main
* 函数功能 : 主函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
//液晶显示位置函数
void lcd_pos(uchar x,uchar y) //从第X行的第Y位置开始显示
{
uchar pos;
if(x==1) //第一行
{ x=0x80;}
else if(x==2) //第二行
{ x=0x90;}
else if(x==3) //第三行
{ x=0x88;}
else if(x==4) //第四行
{ x=0x98;}
pos=x+y-1; //首地址为0X80
LcdWriteCom(pos);
}
//液晶写一个字符串函数
void lcd_write_string(uchar *str)
{
while(*str!='\0') //未结束
{
LcdWriteData(*str++);
Lcd1602_Delay1ms(1);
}
}
void chushihua()
{
TMOD=0x01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
TH1=(65536-1000)/256;
TL1=(65536-1000)%256;
EA=1;ET0=1;TR0=1;
ET1=1;TR1=0;
}
void main(void)
{
u8 i=5;
chushihua();
LcdInit();
lcd_pos(1,1);
lcd_write_string("内蒙古电子学院");
lcd_pos(2,1);
lcd_write_string("----毕业设计----");
lcd_pos(3,1);
lcd_write_string("汽车故障设置仪");
Lcd1602_Delay1ms(2000);
LcdWriteCom(0x01);
chushihua();
lcd_pos(1,1);
lcd_write_string("设计人:");
lcd_pos(2,1);
lcd_write_string("王泽伟、韩鑫宇");
lcd_pos(3,1);
lcd_write_string(" 刘孟君 ");
lcd_pos(4,1);
lcd_write_string("指导教师:宋伟");
Lcd1602_Delay1ms(2000);
LcdWriteCom(0x01);
while(1)
{
chushihua();
lcd_pos(1,1);
lcd_write_string("故障一:");
if(yg1==1){lcd_pos(1,8);lcd_write_string("←");TR1=0;}
else {lcd_pos(1,8);lcd_write_string("← ");TR1=1;}
lcd_pos(2,1);
lcd_write_string("故障二:");
lcd_pos(3,1);
lcd_write_string("故障三:");
lcd_pos(4,1);
lcd_write_string("故障四:");
while(1);
}
}
|