標題:
DS18B20在lcd12864液晶屏上顯示
[打印本頁]
作者:
慕邪丶晴楓
時間:
2017-5-11 21:19
標題:
DS18B20在lcd12864液晶屏上顯示
本程序分為DS18B20、頭文件、12864液晶和主程序四個部分
0.png
(65.41 KB, 下載次數: 100)
下載附件
2017-5-11 21:32 上傳
單片機源程序如下:
//*************************************************************************
// 初始化IO口子程序
//*************************************************************************
void Port_init()
{
P4SEL = 0x00;
P4DIR = 0xFF;
P5SEL = 0x00;
P5DIR|= BIT0 + BIT1 + BIT5 + BIT6 + BIT7;
PSB_SET; //液晶并口方式
RST_SET;
}
//***********************************************************************
// 顯示屏命令寫入函數
//***********************************************************************
void LCD_write_com(unsigned char com)
{
RS_CLR;
RW_CLR;
EN_SET;
DataPort = com;
delay_ms(5);
EN_CLR;
}
//***********************************************************************
// 顯示屏數據寫入函數
//***********************************************************************
void LCD_write_data(unsigned char data)
{
RS_SET;
RW_CLR;
EN_SET;
DataPort = data;
delay_ms(5);
EN_CLR;
}
//***********************************************************************
// 顯示屏清空顯示
//***********************************************************************
void LCD_clear(void)
{
LCD_write_com(0x01);
delay_ms(5);
}
//***********************************************************************
//函數名稱:DisplayCgrom(uchar hz)顯示CGROM里的漢字
//***********************************************************************
void DisplayCgrom(uchar addr,uchar *hz)
{
LCD_write_com(addr);
delay_ms(5);
while(*hz != '\0')
{
LCD_write_data(*hz);
hz++;
delay_ms(5);
}
}
//***********************************************************************
// 顯示屏單字符寫入函數
//***********************************************************************
void LCD_write_char(unsigned char x,unsigned char y,unsigned char data)
{
if (y == 0)
{
LCD_write_com(0x80 + x); //第一行顯示
}
if(y == 1)
{
LCD_write_com(0x90 + x); //第二行顯示
}
if (y == 2)
{
LCD_write_com(0x88 + x); //第三行顯示
}
if(y == 3)
{
LCD_write_com(0x98 + x); //第四行顯示
}
delay_ms(1);
LCD_write_data(data);
delay_ms(1);
}
//***********************************************************************
// 顯示屏字符串寫入函數
//***********************************************************************
void LCD_write_str(unsigned char x,unsigned char y,unsigned char *s)
{
if (y == 0)
{
LCD_write_com(0x80 + x); //第一行顯示
}
if(y == 1)
{
LCD_write_com(0x90 + x); //第二行顯示
}
if (y == 2)
{
LCD_write_com(0x88 + x); //第三行顯示
}
if(y == 3)
{
LCD_write_com(0x98 + x); //第四行顯示
}
delay_ms(2);
while (*s)
{
LCD_write_data( *s);
delay_ms(2);
s ++;
}
}
//***********************************************************************
// 顯示屏初始化函數
//***********************************************************************
void LCD_init(void)
{
LCD_write_com(FUN_MODE); //顯示模式設置
delay_ms(5);
LCD_write_com(FUN_MODE); //顯示模式設置
delay_ms(5);
LCD_write_com(CURSE_DIR); //顯示模式設置
delay_ms(5);
LCD_write_com(DISPLAY_ON); //顯示開
delay_ms(5);
LCD_write_com(CLEAR_SCREEN); //清屏
delay_ms(5);
}
//***********************************************************************
// 液晶顯示界面初始化
//***********************************************************************
void LCD_Desk(void)
{
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
完整資料打包下載:
DS18B20_12864.zip
(63.25 KB, 下載次數: 90)
2017-5-11 21:18 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
cduhuapu
時間:
2017-12-13 12:57
很好的東東,謝謝啦
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1