Write_LCD_Command(0x01); delay50us(10);//清屏 }
//-----------在LCD上显示字符串-----------------*/ void LCD_Display(uchar *str) {
uchar i;
for(i=0;i Write_LCD_Data(str[i]); delay50us(100); } } unsigned long dat_adc0808; uchar display_buffer[][16]={ {\ {\ }; uint adc0808_init() // AD初始化 { START=0; START=1; START=0; while(EOC==0); OE=1; delay50us(20); dat_adc0808=P1; OE=0; return dat_adc0808; } void Refresh_show() //刷新显示 { uint t=dat_adc0808*500.0/255; // if(t>400||t<100)//报警的上下限设置 AB2=1; else 16 AB2=0; display_buffer[1][3] = t/100+'0'; //整数位 display_buffer[1][5] = t/10+'0'; //两个小数位 display_buffer[1][6] = t+'0'; } void main() { TMOD=0x02; TH0=0x14; TL0=0x00; EA=1; ET0=1; TR0=1; Initialize_LCD1602(); delay50us(10); Write_LCD_Command(0x80);//设置显示的初始位置 LCD_Display(display_buffer[0]); //显示测得的数据 while(1) { if(AB3==1) { Write_LCD_Command(0xc0);//设置显示的初始位置 LCD_Display(display_buffer[1]); //显示测得的数据 } else{ adc0808_init(); Refresh_show(); //更新测的电压数据 Write_LCD_Command(0xc0);//设置显示的初始位置 LCD_Display(display_buffer[1]); //显示测得的数据 } } } void Timer0_INT() interrupt 1 using 1 { CLOCK=!CLOCK; } 17