EN_CLR; }
void LCD_clear(void) {
LCD_write_com(0x01); delay_ms(10); }
void LCD_init(void) {
LCD_write_com(0x38); delay_ms(10);
LCD_write_com(0x38); delay_ms(10);
LCD_write_com(0x38); delay_ms(10);
LCD_write_com(0x38); LCD_write_com(0x08); LCD_write_com(0x01); LCD_write_com(0x06); delay_ms(10);
LCD_write_com(0x0C); }
adc_init() {
DDRA&=~BIT(0); PORTA&=~BIT(0);
ADMUX|=0x40; ADCSRA=0XE0; SFIOR=0X00; SREG|=BIT(7); }
void data_pro(uint temp_l,uint temp_h) {
uint temp1,temp2,bb,i; temp1=temp_h*256; temp2=temp1+temp_l;
temp2=(temp2*46-1700)/10; if(temp2<50) temp2=0;
if(temp2>5000)
16
temp2=0;
table[3]=temp2/1000; temp1=temp200; table[2]=temp1/100; temp2=temp10; table[1]=temp2/10; table[0]=temp2; }
void delay_ms(uchar z) {
uchar x,y;
for(x=z;x>0;x--)
for(y=1000;y>0;y--); }
void main() {
DDRC=0XFF; DDRA=0XFF; DDRB=0XFF; DDRD=0XFF; LCD_init(); adc_init();
while(1) {
uint adc_l,adc_h; adc_l=ADCL; adc_h=ADCH;
data_pro(adc_l,adc_h); LCD_write_com(0x84);
LCD_write_Data(0x30+table[3]); LCD_write_Data(0x2e);
LCD_write_Data(0x30+table[2]); LCD_write_Data(0x30+table[1]); LCD_write_Data(0x20); LCD_write_Data(0x4b); LCD_write_Data(0x67);
delay_ms(200); } }
17
附录2 总硬件电路图
18
附录3 实物图
19