#include <reg51.h>
#include <stdio.h>
#define DATA_BUS (P0)
#define RS (P2_bit.P2_0)
#define RW (P2_bit.P2_1)
#define E (P2_bit.P2_2)
#define LED (P2_bit.P2_4)
typedef unsigned char uchar;
typedef unsigned int uint;
void init()
{
uchar i;
TMOD=0x01;
TH0=(65535-2000)/256;
TL0=(65535-2000)%256;
EA=1;
ET0=1;
TR0=1;
RW=0;
LED=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
for(i=0;i<16;i++)
write_date(table[i]);
delay(5);
}
write_com(0x80+0x40);
for(i=0;i<8;i++)
{
write_date(table1[i]);
delay(5);
}
}
void display()
{
write_com(0x80+0x40);
write_date(d/1000+'0');
write_com(0x80+0x40+1);
write_date(d/100%10+'0');
write_com(0x80+0x40+3);
write_date(d/10%10+'0');
if(CH==0)
{
write_com(0x80+0x40+8);
write_date('0');
}
if(CH==1)
{
write_com(0x80+0x40+8);
write_date('1');
}
}
18
void main()
{
init();
while(1)
{
display();
}
}
void
timer0() interrupt 1
{
if(K1==0)
{
delay(1);
19
if(K1==0)
{
while(!K1);
LED=~LED;
CH=(++CH)%2;
d=Get_AD_Result()*2500.0/255;
}
}
TH0=(65535-2000)/256;
TL0=(65535-2000)%256;
}
你具体想问什么呢?
一周热门 更多>