/*****************************************************************************************************************************************
*Author:JYW
*Time:2019_02_13
*Describe:LetAllLinesOfCodeSpeak
*****************************************************/
/************************************
*手把手教你学单片机代码练习*/
#include<reg52.h>
#define Lcd1602_DB P0
sbit Lcd1602_RS = P1^0;
sbit Lcd1602_RW = P1^1;
sbit Lcd1602_E = P1^5;
bit flag500ms = 0;//500ms定时标志
unsigned char T0RH = 0;//T0重载值的高字节
unsigned char T0RL = 0;//T0重载值的低字节
unsigned char code str1[] = "Kingst Studio";
unsigned char code Str2[] = "Let's move";
void ConfigTime0(unsigned char ms);
void InitLcd1602();
void LcdshowStr(unsigned char x,unsigned char y,
unsigned char *str,unsigned char len);
void main()
{
unsigned char i = 0;
unsigned char index = 0;
unsigned char pdata bufMove1[16+sizeof(str1)+16];
unsigned char pdata bufMove2[16+sizeof(Str2)+16];
EA = 1;
ConfigTimer0(10);//配置定时10ms;
InitLcd1602();
for(i= 0; i<16;i++)
{
bufMove1[i] = ' ';
bufMove2[i] = ' ';
}
for(i = 0; i<(sizeof(str1)-1);i++)
{
bufMove1[16 + i] = str1[i];
bufMove2[16 + i] = str2[i];
}
for(i=(16 + sizeof(str1)-1);i<sizeof(bufMove1); i++)
{
bufMove1[i] = ' ';
bufMove2[i] = ' ';
}
while(1)
{
if(flag500ms)//
{
flag500ms = 0 ;
LcdShowStr(0,0,bufMove1 + index,16);
LcdShowStr(0,1,bufMove2 + index,16);
index++;
if(index >= (16+ sizeof(str1)-1))
{
index = 0;
}
}
}
}
}