- #include<reg51.h>
- #include<string.h>
- #define uchar unsigned char
- #define uint unsigned int
- void Initialize_LCD();
- void DelayMS(uint ms);
- void ShowString(uchar,uchar,uchar *);
- sbit K1=P3^2;
- uchar const Line_Count=2;
- uchar code Msg[][80]={
- "welcome to HeiLongJiang polytechnic!",
- "2015-2-3 9:09:09",
- };
- uchar Disp_Buffer[32];
- void H_Scroll_Display()
- {
- uchar i,j;
- uchar *p=Msg[0];
- uchar *q=Msg[0]+strlen(Msg[0]);
- for(i=0;i<16;i++)Disp_Buffer[ i]=' ';
- while(p<q)
- {
- if((i==16||i==31)&&*p==' ')p++;
- for(i=16;i<32&&p<q;i++)
- {
- if(*p!='\0')
- {
- Disp_Buffer[ i]=*p++;
- }
- else
- break;
- }
- for(j=i;j<32;j++)Disp_Buffer[j]=' ';
- for(i=0;i<=16;i++)
- {
- while(F0)DelayMS(100);
- ShowString(0,0,Disp_Buffer+i);
- while(F0)DelayMS(100);
- DelayMS(200);
- }
- DelayMS(300);
- }
- }
- void EX_INT0() interrupt 0
- {
- F0=!F0;
- }
- void main()
- {
- uint Count=0;
- IE=0x81;
- IT0=1;
- F0=0;
- Initialize_LCD();
- while(1)
- {
- ShowString(0,1,Msg[1]);
- H_Scroll_Display();
- DelayMS(300);
- }
- }
复制代码
|