原创 C51 温湿度传感器DHT11驱动 LCD1602显示程序 硬件通过 含电路图和实际测试效果图
/**************************************************************************** * 名 称:Init_Lcd() 主函数调用
* 功 能:Lcd初始化
* 入口参数:无
* 出口参数:无
* 范 例: 在主函数中直接调用
****************************************************************************/
void Init_Lcd() //LCD初始化
{
LCD_write_char(0x38,0);
Delay_ms(1);
LCD_write_char(0x38,0);
Delay_ms(1);
LCD_write_char(0x38,0);
Delay_ms(1);
LCD_write_char(0x0c,0);
Delay_ms(1);
LCD_write_char(0x06,0);
Delay_ms(1);
LCD_write_char(0x0c,0);
Delay_ms(1);
//
}
/**************************************************************************** * 名 称:LCD_write_str(uchar X,uchar Y,uchar *s)主函数调用
* 功 能:在指定地址写一个字符串 eg:Y=0,1,2,3,4,5,6,7,8,9,10...15。 X=0,1。 * 入口参数:X:横坐标 Y:纵坐标 *s:字符串首地址
* 出口参数:无
* 范 例: LCD_write_str(1,1,uchar *s)
****************************************************************************/ void LCD_write_str(unsigned char X,unsigned char Y,unsigned char *s)
{
LCD_write_char(0,' ');
LCD_set_xy( X, Y ); //写地址
while (*s) // 写显示字符
{
LCD_write_char( 0, *s );
s ++;
}