|
無標(biāo)題.png (22.17 KB, 下載次數(shù): 86)
下載附件
2021-3-14 09:04 上傳
單片機(jī)源程序如下:
- /*---------------------------------------------------------------------
- LCD1602.C文件 LCD1602的函數(shù)
- ----------------------------------------------------------------------*/
- #include "hardware.h"
- #include "lcd1602.h"
- void LCD_check_busy(void) //檢測LCD狀態(tài),看它是不是還在忙呢
- {
- while(1)
- {
- LCD_EN=0;
- LCD_RS=0;
- LCD_RW=1;
- LCD_DATA=0xff;
- LCD_EN=1;
- if(!LCD_BUSY)break;
- }
- LCD_EN=0;
- }
- void LCD_cls(void) //LCD清屏
- {
-
- LCD_check_busy();
- LCD_RS=0;
- LCD_RW=0;
- LCD_DATA=1;
- LCD_EN=1;
- LCD_EN=0;
-
- }
- void LCD_write_instruction(unsigned char LCD_instruction) //寫指令到LCD
- {
- LCD_check_busy();
- LCD_RS=0;
- LCD_RW=0;
-
- LCD_DATA=LCD_instruction;
- LCD_EN=1;
- LCD_EN=0;
- }
- void LCD_write_data(unsigned char LCD_data) //輸出一個(gè)字節(jié)數(shù)據(jù)到LCD
- {
- LCD_check_busy();
- LCD_RS=1;
- LCD_RW=0;
-
- LCD_DATA=LCD_data;
- LCD_EN=1;
- LCD_EN=0;
- }
-
- void LCD_set_position(unsigned char x) //LCD光標(biāo)定位到x處
- {
- LCD_write_instruction(0x80+x);
- }
- /*
- void LCD_go_home(void) //LCD光標(biāo)歸位
- {
- LCD_write_instruction(LCD_GO_HOME);
- }
- */
- void LCD_printc(unsigned char lcd_data) //輸出一個(gè)字符到LCD
- {
- LCD_write_data(lcd_data);
- }
- void LCD_prints(unsigned char *lcd_string) //輸出一個(gè)字符串到LCD
- {
- unsigned char i=0;
- while(lcd_string[i]!=0x00)
- {
- LCD_write_data(lcd_string[i]);
- i++;
- }
- }
- void LCD_initial(void) //初始化LCD
- {
- LCD_write_instruction(LCD_AC_AUTO_INCREMENT|LCD_MOVE_DISENABLE);
- LCD_write_instruction(LCD_DISPLAY_ON|LCD_CURSOR_OFF);
- LCD_write_instruction(LCD_DISPLAY_DOUBLE_LINE);
- LCD_cls();
- }
復(fù)制代碼
所有資料51hei提供下載:
項(xiàng)目.zip
(73.85 KB, 下載次數(shù): 18)
2021-3-14 09:05 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|