#include<reg52.h>
#include<stdlib.h>
#define uint unsigned int
#define uchar unsigned char
sbit wr=P2^5;
sbit rs=P2^6;
sbit e=P2^7;
sbit psb=P3^2;
sbit key1=P3^1;
sbit key2=P3^0;
uchar k,flag;
uchar code table[]="在破败中崛起 ,在寂灭中复苏 ,沧海成尘 ,雷电枯竭 ,那一缕幽雾又一次临近大地 ,世间的枷锁被打开了 ,一个全新的世界就此揭开 ";
void delayms(uint x)
{
uchar y;
for(;x>0;x--)
for(y=110;y>0;y--);
}
void timeinit()
{
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void write_com(uchar com)
{
wr=0;
rs=0;
e=0;
P0=com;
delayms(1);
e=1;
delayms(1);
e=0;
}
void write_date(uchar date)
{
wr=0;
rs=1;
e=0;
P0=date;
delayms(1);
e=1;
delayms(1);
e=0;
}
void init()
{
psb=1;
write_com(0x30);
delayms(2);
write_com(0x0c);
delayms(2);
write_com(0x01);
delayms(2);
}
void keyscan()
{
if(key1==0)
{
delayms(10);
if(key1==0)
{
write_com(0x01);
k=k+64;
if(k>64) k=0;
}
}
while(!key1);
if(key2==0)
{
delayms(10);
if(key2==0)
{
if(k>0)
k=k-16;
}
}
while(!key2);
}
void main()
{
uchar i;
init();
timeinit();
delayms(5);
while(1)
{
write_com(0x80);
delayms(2);
for(i=0;i<16;i++)
{
write_date(table[i+k]);
delayms(2);
}
write_com(0x90);
delayms(2);
for(i=0;i<16;i++)
{
write_date(table[i+16+k]);
delayms(2);
}
write_com(0x88);
delayms(2);
for(i=0;i<16;i++)
{
write_date(table[i+32+k]);
delayms(2);
}
write_com(0x98);
delayms(2);
for(i=0;i<16;i++)
{
write_date(table[i+48+k]);
delayms(2);
}
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
keyscan();
}
|