#include<reg51.h>
#include<intrins.h>
sbit rs = P3^5;
sbit rw = P3^6;
sbit ep = P3^7;
unsigned char code dis1[] ={0x00,0xF0,0x0F,0x10,0x08,0x10,0x0F,0xA0,0x08,0x20,0x07,0xC0,0x00,0x00,0x01,0xF8,
0x1E,0x08,0x10,0xC8,0x1F,0x08,0x10,0x08,0x0F,0xD0,0x00,0x30,0x00,0x10,0x00,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xFC,0x7F,0x00,0x01,0x00,0x01,0xF0,
0x0F,0x00,0x00,0x00,0x03,0xF0,0x0C,0x10,0x08,0x20,0x07,0xE0,0x04,0x00,0x00,0x00,
0x00,0x20,0x12,0x20,0x09,0x20,0x00,0x40,0x23,0xFC,0x3C,0x08,0x63,0xC0,0x44,0x80,
0x01,0x00,0x01,0xF8,0x7E,0x80,0x00,0x80,0x00,0x80,0x02,0x80,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x78,0x40,0x4A,0xF8,0x53,0x08,0x54,0x60,0x69,0x80,0x58,0x70,
0x43,0xC0,0x41,0x40,0x42,0x44,0x44,0x44,0x48,0x44,0x50,0x38,0x00,0x00,0x00,0x00 };
unsigned char code dis2[] ={"www.adu0228.com"};
void delay(unsigned char ms)
{
unsigned char i;
while(ms--)
{
for(i=0; i<250; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
bit lcd_bz()
{
bit result;
rs = 1;
rw = 0;
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
result = (bit)(P1 & 0x80);
ep = 0;
return result;
}
void lcd_wcmd(unsigned char cmd)
{
while(lcd_bz()); //判断LCD是否忙碌
rs = 0;
rw = 0;
ep = 0;
_nop_();
_nop_();
P1 = cmd;
_nop_();
_nop_();
// _nop_();
// _nop_();
ep = 1;
_nop_();
_nop_();
// _nop_();
// _nop_();
ep = 0;
}
void lcd_pos(unsigned char pos)
{
lcd_wcmd(pos | 0x80);
}
void lcd_wdat(unsigned char dat)
{
while(lcd_bz());//判断LCD是否忙碌
rs = 1;
rw = 0;
ep = 0;
P1 = dat;
_nop_();
_nop_();
// _nop_();
// _nop_();
ep = 1;
_nop_();
_nop_();
// _nop_();
// _nop_();
ep = 0;
}
void lcd_init()
{
lcd_wcmd(0x38);
delay(1);
lcd_wcmd(0x0c);
delay(1);
lcd_wcmd(0x06);
delay(1);
lcd_wcmd(0x01);
delay(1);
}
void main(void)
{
unsigned char i;
lcd_init();//初始化LCD
delay(10);
while(1)
{
lcd_pos(0x01);//设置显示位置
i = 0;
while(dis1[i] != ' ')
{
lcd_wdat(dis1[i]);//显示字符
i++;
}
lcd_pos(0x42);//设置显示位置
i =0;
while(dis2[i] != ' ')
{
lcd_wdat(dis2[i]);//显示字符
i++;
}
}
}
这个程序怎么改
一周热门 更多>