我现在用的是16脚蓝光的YM1602 我一接通电源 就只看到32个黑 {MOD}的长方体,跪求专业人士 找错 先谢谢各位i。。
电路图如下:
(原文件名:YM1602.JPG)
程序是:
#include<at89x52.h>
#include<intrins.h>
#define rs P1_7
#define rw P1_6
#define ep P1_5
unsigned char str1[]={"successful"};
void delay(unsigned char n)
{
unsigned char m;
for(n;n>0;n--)
for(m=0;m<110;m++);
}
void lcd_busy()
{
delay(10);
ep=0;
rs=0;
rw=1;
ep=1;
while(P3&0x80);
delay(5);
ep=0;
}
void lcd_write_command(unsigned char command)
{
lcd_busy();
rs=0;
rw=0;
ep=0;
P3=command;
ep=1;
delay(5);
ep=0;
}
void lcd_write_data(unsigned char dat)
{
lcd_busy();
rs=1;
rw=0;
ep=1;
P3=dat;
delay(5);
ep=0;
}
void lcd_init()
{
delay(15);
lcd_write_command(0x38);
delay(2);
lcd_busy();
lcd_write_command(0x0c);
delay(2);
lcd_busy();
lcd_write_command(0x06);
delay(2);
lcd_busy();
lcd_write_command(0x01);
delay(2);
}
void lcd_postion(unsigned char x,unsigned char y)
{
if(y<2)
{
y&=0x01;
x&=0x0f;
if(y==1)
x=x+0x40;
x=x+0x80;
lcd_write_command(x);
}
}
void display(unsigned char x,unsigned char y,unsigned char *s)
{
lcd_postion(x,y);
while((*s)!=' ')
{
lcd_write_data(*s);
s++;
}
}
void main()
{
lcd_init();
lcd_write_command(0x82);
lcd_write_data(0x30);
display(0,1,"hello");
while(1);
}
(原文件名:@({F0M]%~1ZW~2})`OS(MFL.jpg)
一周热门 更多>