您好,歡迎來電子發(fā)燒友網(wǎng)! ,新用戶?[免費(fèi)注冊(cè)]

您的位置:電子發(fā)燒友網(wǎng)>源碼下載>C/C++語言編程>

1602液晶C語言經(jīng)典例程

大?。?/span>0.1 MB 人氣: 2017-09-05 需要積分:0
#include
#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)
{???????// 延時(shí)子程序
?BYTE i;
?while(ms--)
?{
??for(i = 0; i< 250; i++)
??{
???_nop_();
???_nop_();
???_nop_();
???_nop_();
??}
?}
}
BOOL lcd_bz()
{???????// 測(cè)試LCD忙碌狀態(tài)
?BOOL result;
?rs = 0;
?rw = 1;
?ep = 1;
?_nop_();
?_nop_();
?_nop_();
?_nop_();
?result = (BOOL)(P0 & 0x80);
?ep = 0;
?return result;?
}
lcd_wcmd(BYTE cmd)
{???????// 寫入指令數(shù)據(jù)到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)
{???????//設(shè)定顯示位置
?lcd_wcmd(pos | 0x80);
}
lcd_wdat(BYTE dat)?
{???????//寫入字符顯示數(shù)據(jù)到LCD
?while(lcd_bz());
?rs = 1;
?rw = 0;

非常好我支持^.^

(0) 0%

不好我反對(duì)

(0) 0%

      發(fā)表評(píng)論

      用戶評(píng)論
      評(píng)價(jià):好評(píng)中評(píng)差評(píng)

      發(fā)表評(píng)論,獲取積分! 請(qǐng)遵守相關(guān)規(guī)定!

      ?