完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
写一个LCD1602程序,显示“Hello world!” #include #define uchar unsigned char uchar code Zimu[]="Hello world!"; ***it Lcd_RS=P1^0; ***it Lcd_RW=P1^1; ***it Lcd_EN=P1^2; ***it Lcd_Busy=P1^3; #define Lcd_Data=P0; void Lcd_Set_Position(uchar position);//设置显示位置 void Lcd_Init(void);//液晶初始化 void Lcd_Write_Com(uchar command);//写命令 void Lcd_Write_Data(uchar data)//写数据 void Lcd_Display(uchar *P); void main() { Lcd_Inti(); Lcd_Set_Position(0x40); Lcd_Display( Zimu); while(1); } void Lcd_Set_Position(uchar position)//设置显示位置 { Lcd_Write_Com(0x80+position); } void Lcd_Init(void)//液晶初始化 { Lcd_Write_Com(0x38); //设置显示模式 Lcd_Write_Com(0x0c); //开显示不显示光标,光标不闪烁 Lcd_Write_Com(0x06); //写一个指针加1 Lcd_Write_Com(0x01); //清屏 Lcd_Write_Com(0x80); //设置数据指针 } void Lcd_Write_Com(uchar command)//写命令 { Lcd_Check_Busy(); Lcd_RS=0; Lcd_RW=0; Lcd_Data=command; Lcd_EN=1; Lcd_EN=0; } void Lcd_Check_Busy(void)//查询忙碌 { while(1) { Lcd_EN=0; Lcd_RS=0; Lcd_RW=1; Lcd_EN=1; if(Lcd_Busy==0)break; Lcd_EN=0; } } void Lcd_Write_Data(uchar data)//写数据 { Lcd_Check_Busy(); Lcd_RS=1; Lcd_RW=0; Lcd_Data=data; Lcd_EN=1; Lcd_EN=0; } void Lcd_Display(uchar * P)//字符串显示子程序 { uchar i,temp; i=0; while(1) { temp=P; Lcd_Write_Data(temp); i++; if(temp==' |