1602液晶C語言經典例程
大小:0.1 MB 人氣: 2017-09-05 需要積分:0
#include
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef bit BOOL ;
sbit rs?= P2^5;??//
sbit rw = P2^6;
sbit ep = P2^7;
BYTE code dis1[] = {"pp51.com"};
BYTE code dis2[] = {"http://pp51.com"};
delay(BYTE ms)
{???????// 延時子程序
?BYTE i;
?while(ms--)
?{
??for(i = 0; i< 250; i++)
??{
???_nop_();
???_nop_();
???_nop_();
???_nop_();
??}
?}
}
BOOL lcd_bz()
{???????// 測試LCD忙碌狀態
?BOOL result;
?rs = 0;
?rw = 1;
?ep = 1;
?_nop_();
?_nop_();
?_nop_();
?_nop_();
?result = (BOOL)(P0 & 0x80);
?ep = 0;
?return result;?
}
lcd_wcmd(BYTE cmd)
{???????// 寫入指令數據到LCD
?while(lcd_bz());
?rs = 0;
?rw = 0;
?ep = 0;
?_nop_();
?_nop_();?
?P0 = cmd;
?_nop_();
?_nop_();
?_nop_();
?_nop_();
?ep = 1;
?_nop_();
?_nop_();
?_nop_();
?_nop_();
?ep = 0;??
}
lcd_pos(BYTE pos)
{???????//設定顯示位置
?lcd_wcmd(pos | 0x80);
}
lcd_wdat(BYTE dat)?
{???????//寫入字符顯示數據到LCD
?while(lcd_bz());
?rs = 1;
?rw = 0;
非常好我支持^.^
(0) 0%
不好我反對
(0) 0%