#include <REGX52.H>
#define LCD_DB P0
sbit LCD_RS=P2^6;
sbit LCD_RW=P2^7;
sbit LCD_E=P2^6;
unsigned char PuZh[]="Prechin Science";
void delay1ms(unsigned int c) //误差 0us
{
unsigned char a,b;
for (; c>0; c--)
{
for (b=199;b>0;b--)
{
for(a=1;a>0;a--);
}
}
}
void delay(unsigned int t)
{
unsigned int a;
a=t;
while(a--);
}
void LCDWriteCom(unsigned int com)
{
LCD_E=0;
LCD_RS=0;
LCD_RW=0;
LCD_DB=com;
delay1ms(10);
LCD_E=1;
delay1ms(10);
LCD_E=0;
}
void LCDWriteData(unsigned int dat)
{
LCD_E=0;
LCD_RS=1;
LCD_RW=0;
LCD_DB=dat;
delay1ms(10);
LCD_E=1;
delay1ms(10);
LCD_E=0;
}
void LCDInit()
{
LCDWriteCom(0x38); //设置显示模式
delay1ms(1);
LCDWriteCom(0x0c); //开显示,不显示光标,光标不闪烁
delay1ms(1);
LCDWriteCom(0x06); //写一个指针加1
delay1ms(1);
LCDWriteCom(0x01); //清屏
delay1ms(1);
LCDWriteCom(0x80); //设置数据指针起点
delay1ms(1);
}
void main ()
{
unsigned char i;
LCDInit();
for(i=0;i<16;i++)
{
LCDWriteData(PuZh[i]);
delay1ms(1);
}
while(1)
{
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>