中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

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

        LCD1602程序代碼及顯示流程圖

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

          lcd1602顯示程序代碼

          

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

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

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

          // - - 初始化接口

          # 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ù)。我沒用到此函數(shù),因?yàn)橥ㄟ^率極低。

          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!=‘