📄 lcd1602.c
字号:
//#include<reg51.h>
sbit rs=P0^5;
sbit rw=P0^6;
sbit E=P0^7;
//...延时函数
void Delay(unsigned int a)
{
for(a=a*100;a>0;a--);
}
///////////////////
// ..........................以下为液晶模块在程序
//////////////
void WriteC(unsigned c)
{rw=0;
rs=0;
E=1;
P2=c;
Delay(1); //0.1ms
E=0;
// rw=1;
}
//////////////
void WriteD(unsigned char d)
{rw=0;
rs=1;
E=1;
P2=d;
Delay(1); //0.1ms
E=0;
//rw=1;
}
//////////////
void InitLCD(void) //初始化液晶
{ WriteC(0x38);
WriteC(0x0c);
}
/////////////////
//...
void GB(void)
{ WriteC(0x0e);
//WriteC(0x10);//
//WriteC(0x14);//
//WriteC(0x0e);//
WriteC(0x06);//
}
void ClearLCD(void)
{ WriteC(0x01);
WriteC(0x02);
}
////////////////////
void Display_string(char *p)
{ while(*p)
{ WriteD(*p);
p++;
}
}
/////////////////
/*
void GotoXY(unsigned char x, unsigned char y)
{
if(y==0)
LCD_Write(LCD_COMMAND,0x80|x);
if(y==1)
LCD_Write(LCD_COMMAND,0x80|(x-0x40));
}*/
void Print(unsigned char *str)
{
while(*str!='\0')
{
WriteD(*str);
str++;
}
}
void Gotoxy(unsigned x,unsigned y)
{ if(x==1)WriteC(128+y);
else WriteC(192+y);
}
///////////////////////
// .................以上为液晶模块在程序
/*void main()
{
InitLCD();
//ClearLCD();
Display_string("Hi!Time is:00s");
Gotoxy(2,1);
Display_string("High is:000cm");
//while(1);
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -