#include
#define uchar unsigned char
#define uint unsigned int
sbit as=P1^4;
sbit wr=P1^5;
sbit ds=P1^6;
sbit cs=P1^7;
sbit RW=P1^1;
sbit rs=P1^0;
sbit lcden=P1^2;
void delay1(uint);
void delay2(uint);
void write(uchar,uchar);
void send_add(uchar);
void send_data(uchar);
uchar read(uchar);
uchar table[]="0123456789";
uchar shi,fen,miao,num,c1,c2;
void init();
void delay1(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void delay2(uint j)
{
uint m,n;
for(m=j;m>0;m--)
for(n=125;n>0;n--);
}
void send_add(uchar ADD)
{
P3=ADD;
rs=0;
RW=0;
lcden=0;
delay1(10);
lcden=1;
delay1(10);
lcden=0;
}
void send_data(uchar DATA)
{
P3=DATA;
rs=1;
RW=0;
lcden=0;
delay1(10);
lcden=1;
delay1(10);
lcden=0;
}
void write(uchar add,uchar adata)
{
cs=0;
ds=1;
wr=1;
as=1;
P2=add;
as=0;
wr=0;
P2=adata;
wr=1;
as=1;
cs=1;
}
uchar read(uchar add)
{
uchar ds_adata;
cs=0;
as=1;
ds=1;
wr=1;
P2=add;
as=0;
ds=0;
P2=0xff;
ds_adata=P2;
ds=1;
as=1;
cs=1;
return ds_adata;
}
void init()
{
write(0x0b,0x82);
write(0x0a,0xa0);
write(0x0a,0x20);
write(0x0b,0x02);
send_add(0x38);
send_add(0x0c);
send_add(0x06);
send_add(0x01);
delay2(100);
}
void main()
{
init();
while(1)
{
miao=read(0);
c1=miao%10;
c2=miao/10;
send_add(0x85);
send_data(0x30+c1);
send_add(0x84);
send_data(table[c2]);
}
}
|