»ùÓÚSTC89c52RCµ¥Æ¬»úµÄÖÇÄÜ·çÉÈÉè¼Æ ÏÂÔر¾ÎÄ

¹âµçÐÅϢЭ»áµç×ÓÉè¼Æ¾ºÈü ÖÓÅàÎÄС×é

lcdrs=0; lcden=1; P0=com; lcden=0; }

void write_data(uchar Data) {

Delayms(5); lcdrs=1; lcden=1; P0=Data; ; lcden=0; }

void write_string(uchar x,uchar y,uchar *s) { if (y == 0) {

write_com(0x80 + x); } else {

write_com(0xC0 + x); } while (*s) {

write_data( *s); s ++; }

//дÈë1602×Ö·û´®

29

¹âµçÐÅϢЭ»áµç×ÓÉè¼Æ¾ºÈü ÖÓÅàÎÄС×é

}

void write_char(uchar x,uchar y,uchar Data) { if (y == 0) {

write_com(0x80 + x); } else {

write_com(0xC0 + x); }

write_data(Data); }

void Init_1602(void) {

lcden=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); }

void display2(void) {

write_string(4,0,table_1); write_string(0,1,table_21); write_string(6,1,table_22); }

void change_display2(void)

//³õʼ»¯1602²ÎÊý

//1602д×Ö·û

30

¹âµçÐÅϢЭ»áµç×ÓÉè¼Æ¾ºÈü ÖÓÅàÎÄС×é

{

uchar time_asc[5],a;

time_asc[0]=time2/10000+0x30; time_asc[1]=time2000/1000+0x30; time_asc[2]=time200000/100+0x30; time_asc[3]=time2000000/10+0x30; time_asc[4]=time2000000+0x30; if(timing_on==1) {

for(a=0;a<5;a++)

write_char(11+a,1,time_asc[a]); }

if(timing_flag==0 && timing_on==0) {

write_string(14,1,\ \write_string(11,1,\}

if(run_flag) {

write_string(2,0,\} else

write_string(4,0,table_1); switch(i) {

case 1: write_char(2,1,'1');break; case 2: write_char(2,1,'2');break; case 3: write_char(2,1,'3');break; default: write_char(2,1,'0'); } switch(j) {

case 1: write_char(8,1,'1');break;

31

¹âµçÐÅϢЭ»áµç×ÓÉè¼Æ¾ºÈü ÖÓÅàÎÄС×é

case 2: write_char(8,1,'2');break; case 3: write_char(8,1,'3');break; default: write_char(8,1,'0'); } }

//ºìÍⲿ·Ö /*------------------------------------------------ ÍⲿÖжÏ0Öжϴ¦Àí ------------------------------------------------*/

void Ex0_ir (void) interrupt 0 //ÍⲿÖжÏ0·þÎñº¯Êý {

static unsigned char i; //½ÓÊÕºìÍâÐźŴ¦Àí static bit startflag; //ÊÇ·ñ¿ªÊ¼´¦Àí±ê־λ

if(startflag) {

if((irtime/10)<63&&(irtime>=33))//Òýµ¼Âë TC9012µÄÍ·Â룬9ms+4.5ms

i=0;

irdata[i]=irtime;//´æ´¢Ã¿¸öµçƽµÄ³ÖÐøʱ¼ä£¬ÓÃÓÚÒÔºóÅжÏÊÇ0»¹ÊÇ1 irtime=0; i++; if(i==33) { irok=1; i=0; }

} else { irtime=0; startflag=1;

32