完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include #define uchar unsigned char #define uint unsigned int ***it LCD_RS=P2^0; ***it LCD_RW=P2^1; ***it LCD_EN=P4^5; ***it Busy=P0^7; void delay_ms(uint x) { int i,j; for(j = 0; j < x; j++) { for(i = 0; i < 110; i++) { } } } void mang(void) { while(1) {LCD_RS=0; LCD_RW=1; LCD_EN=0; P0=0xFF; LCD_EN=1; if((P0&Busy)==0) break; } } void write_dat(uchar dat) { mang(); LCD_RS=1; LCD_RW=0; LCD_EN=1; delay_ms(5); P0=dat; delay_ms(5); LCD_EN=0; } void write_cmd(uchar cmd) { LCD_RS=0; LCD_RW=0; LCD_EN=1; delay_ms(5); P0=cmd; delay_ms(5); LCD_EN=0; } void lcd_init() { write_cmd(0x30);//基本操作指令 delay_ms(5); write_cmd(0x0c);//打开显示,光标关闭 delay_ms(5); write_cmd(0x01);//清除LCD显示类容 delay_ms(5); } void display(uchar x,uchar y,uchar *seg) { uchar i; uint t=0; switch(x) { case 1: i=0x80; break; //第一行 case 2: i=0x90; break; //第二行 case 3: i=0x88; break; //第三行 case 4: i=0x98; break; //第四行 default : break; } i=i+y-1; //确定列号 write_cmd(i); while(seg[t]!=' |