在我买的
开发板上显示正常
但是我用
单片机最小系统,连接好
电路,打开
电源,
显示变成了下面这样 ( ̄△ ̄;)
好奇怪呀, 其他的都和开发板上的一样 ,就是
显示字符串不对
( ﹁ ﹁ ) ~→
我在网上查到lcd1602里面有上拉电阻,所以我接电路就直接相连.
程序如下 :
#include<reg52.h>
#define LCD P0
#define delaytime 500
sbit E = P2^7;
sbit RS = P2^6;
sbit RW = P2^5;
unsigned char code display1[] = "My name is Cjl ";
unsigned char code display2[] = "I want to ";
unsigned char code display3[] = "master 89c52 ";
unsigned char code display4[] = "I think that ";
unsigned char code display5[] = "It's interesting";
unsigned char code display6[] = "It's so cool!!!!";
void LCD_Com(unsigned char x);
void LCD_Data(unsigned char x);
void Init1();
void Init2();
void delay(unsigned int x);
void main()
{
unsigned char i;
while(1){
Init1();
for(i = 0; i < 16; i++)
LCD_Data(display1);
delay(delaytime);
Init2();
for(i = 0; i < 16; i++)
LCD_Data(display2);
delay(delaytime);
Init1();
for(i = 0; i < 16; i++)
LCD_Data(display3);
delay(delaytime);
Init2();
for(i = 0; i < 16; i++)
LCD_Data(display4);
delay(delaytime);
Init1();
for(i = 0; i < 16; i++)
LCD_Data(display5);
delay(delaytime);
Init2();
for(i = 0; i < 16; i++)
LCD_Data(display6);
delay(delaytime);
}
}
void LCD_Com(unsigned char x)
{
RS = 0;
RW = 0;
LCD = x;
delay(10);
E = 1;
delay(10);
E = 0;
}
void LCD_Data(unsigned char x)
{
RS = 1;
RW = 0;
LCD = x;
delay(10);
E = 1;
delay(10);
E = 0;
}
void Init1()
{
LCD_Com (0x38);
LCD_Com (0x0c);
LCD_Com (0x06);
LCD_Com (0x01);
LCD_Com (0x80);
}
void Init2()
{
LCD_Com (0x38);
LCD_Com (0x0c);
LCD_Com (0x06);
// LCD_Com (0x01);
LCD_Com (0xc0);
}
void delay(unsigned int x)
{
unsigned int i, j;
for(i = x; i > 0; i--)
for(j = 110; j > 0; j--)
;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>