#include <reg52.h> #define uint unsigned int #define uchar unsigned char /* *************************** PIN *************************/ #define LCD1602_DB P0// sbit LCD1602_RS=P2^5; sbit LCD1602_RW=P2^6; sbit LCD1602_EN=P2^7; /* ***************************** */ void LCD1602_check_busy(void) { unsigned char sta; LCD1602_DB=0xff; LCD1602_RS=0; LCD1602_RW=1; do { LCD1602_EN=1; sta=LCD1602_DB; LCD1602_EN=0; }while(sta & 0x80); } void wrcmd1602(char cmd) { LCD1602_check_busy(); LCD1602_RS=0; LCD1602_RW=0; LCD1602_DB=cmd; LCD1602_EN=1; LCD1602_EN=0; } void wrdata1602(char mdata) { LCD1602_check_busy(); LCD1602_RS=1; LCD1602_RW=0; LCD1602_DB=mdata; LCD1602_EN=1; LCD1602_EN=0; } void LcdSetCursor(unsigned char x,unsigned char y) { unsigned char addr; if(x==0) addr=0x00 + y; else addr=0x40 + y; wrcmd1602(0x80+addr); } void LcdShowStr(unsigned char x,unsigned char y,unsigned char *str) { LcdSetCursor(x,y); while(*str!='