标题:
为什么单片机+LCD1602无法显示?并且P0.5端口有问题,怎么解决?
[打印本页]
作者:
IJLG
时间:
2020-3-24 13:25
标题:
为什么单片机+LCD1602无法显示?并且P0.5端口有问题,怎么解决?
#define LCD_DB P0
sbit LCD_E=P2^0;
sbit LCD_RW=P2^1;
sbit LCD_RS=P2^2;
u8 disp[]=" dripping speed ";
void LCD_init()
{
LCD_write_command(0x38);
LCD_write_command(0x0c);
LCD_write_command(0x06);
LCD_write_command(0x01);
LCD_write_command(0x80);
}
void LCD_write_command(unsigned char com)
{
LCD_E=0;
LCD_RS=0;
[color=#007000][backcolor=rgb(255, 255, 255)][font=Tahoma,] LCD[/font][/backcolor][/color]_RW=0;
LCD_DB=com;
delay(1000);
LCD_E=1;
delay(5000)
LCD_E=0;
}
void LCD_write_data(unsigned char dat)
{
LCD_E=0;
LCD_RS=1;
LCD_RW=0;
LCD_DB=dat
delay(1000);
LCD_E=1
delay(5000)
LCD_E=0;
}
void main()
{
u8 i;
LCD_init();
for(i=0;i<16;i++)
{
LCD_write_data(disp[i]);
}
while(1);
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1