在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 光電顯示 > 設(shè)計(jì)應(yīng)用 > LCD1602程序代碼及顯示流程圖

            LCD1602程序代碼及顯示流程圖

            作者: 時(shí)間:2017-10-14 來(lái)源:網(wǎng)絡(luò) 收藏

              lcd1602顯示程序代碼

              

            本文引用地址:http://www.biyoush.com/article/201710/366255.htm

              前些天弄了最小系統(tǒng)板后就想著學(xué)習(xí)1602的顯示程序,可惜壇子里的或網(wǎng)上的,都沒(méi)有簡(jiǎn)單的1602顯示程序,無(wú)柰在網(wǎng)上下載了一段經(jīng)過(guò)反復(fù)修改測(cè)試,終于有了下面一段代碼:

              // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

              // - - 初始化接口

              # define LCD_DB P0 // - - P0 = DB0~DB7

              sbit LCD_RS=P2^0; // - - p2.0 = RS

              sbit LCD_RW=P2^1; // - - p2.1 = RW

              sbit LCD_E=P2^2; // - - p2.2 = E

              // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

              // - - 定義函數(shù)

              # define uchar unsigned char

              # define uint unsigned int

              // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

              // - - 定義子程序函數(shù)

              void LCD_init(void); // - - 初始化函數(shù)

              void LCD_write_command(uchar command); // - - 向寫指令函數(shù)

              void LCD_write_data(uchar dat); // - - 向寫數(shù)據(jù)函數(shù)

              void LCD_set_xy(uchar x,uchar y); // - - 設(shè)置LCD1602顯示位置 X(0-16),y(1-2)

              void LCD_disp_char(uchar x,uchar y,uchar dat); // - - 在LCD1602上顯示一個(gè)字符

              void LCD_disp_string(uchar X,uchar Y,uchar *s); // - - 在LCD1602上顯示一個(gè)字符串

              //void LCD_check_busy(void);//檢查忙函數(shù)。我沒(méi)用到此函數(shù),因?yàn)橥ㄟ^(guò)率極低。

              void LCD_delay_10us(uint n); // - - 10微秒的延時(shí)子程序

              void LCD_delay_50us(uint n); // - - 50微秒的延時(shí)子程序

              // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

              // - - 初始化LCD1602

              void LCD_init(void)

              {

              LCD_delay_10us(20);

              LCD_write_command(0x38); // - - 設(shè)置8位格式,2行,5x7

              LCD_delay_10us(5);

              LCD_write_command(0x0c); // - - 整體顯示,關(guān)光標(biāo),不閃爍

              LCD_delay_10us(5);

              LCD_write_command(0x06); // - - 設(shè)定輸入方式,增量不移位

              LCD_delay_10us(5);

              LCD_write_command(0x01); // - - 清除屏幕顯示

              LCD_delay_50us(40);

              }

              //********************************

              // - - 向LCD1602寫指令

              void LCD_write_command(uchar dat)

              {

              LCD_delay_10us(5);

              LCD_RS=0; // - - 指令

              LCD_RW=0; // - - 寫入

              LCD_DB=dat;

              LCD_delay_10us(5);

              LCD_E=1; // - - 允許

              LCD_delay_10us(5);

              LCD_E=0;

              }

              // - - 向LCD1602寫數(shù)據(jù)

              void LCD_write_data(uchar dat)

              {

              LCD_delay_10us(5);

              LCD_RS=1;// - - 數(shù)據(jù)

              LCD_RW=0;// - - 寫入

              LCD_DB=dat;

              LCD_delay_10us(5);

              LCD_E=1;// - - 允許

              LCD_delay_10us(5);

              LCD_E=0;

              }

              // - - 設(shè)置顯示位置

              void LCD_set_xy(uchar x,uchar y)

              {

              uchar address;

              if(y==1)

              {

              address=0x80+x; // - - 第一行位置

              } else {

              address=0xc0+x; // - - 第二行位置

              }

              LCD_delay_10us(5);

              LCD_write_command(address);

              }

              // - - 顯示一個(gè)字符函數(shù)

              void LCD_disp_char(uchar x,uchar y,uchar dat) // - - LCD_disp_char(0,1,0x38); // - - 顯示8

              {

              LCD_set_xy(x,y);

              LCD_delay_10us(5);

              LCD_write_data(dat);

              }

              // - - 顯示一個(gè)字符串函數(shù)

              void LCD_disp_string(uchar x,uchar y,uchar *s)

              {

              LCD_set_xy(x,y);

              LCD_delay_10us(5);

              while(*s!=‘