基于51单片机的酒精测试仪设计毕业设计说明书 下载本文

ep0;

return result;

lcd_wcmdunsigned char cmd //写指令数据到LCD

whilelcd_bz rs0; rw0; ep0; _nop_; _nop_; P0cmd; _nop_; _nop_; ep1; _nop_; _nop_; ep0;

lcd_posunsigned char pos //

设定显示位置 lcd_wcmdpos | 0x80;

lcd_wdatunsigned char dat //写入显示数据到LCD

whilelcd_bz; rs1; rw0; ep0; P0dat; _nop_; _nop_; ep1; _nop_; _nop_; ep0;

lcd_init //LCD初始化

lcd_wcmd0x38; delay1; lcd_wcmd0x0c;

delay1; lcd_wcmd0x06; delay1; lcd_wcmd0x01; delay1;

Init_DS18B20void //DS18B20初始化

unsigned char x0; DQ1; delay28; DQ0; delay285; DQ1; delay214; delay220;

ReadOneCharvoid // 向DS18B20读一字节数据

unsigned char i0;

unsigned char dat0; fori8;i0;i-- DQ1; delay21; DQ0; dat1; DQ1; ifDQ dat|0x80; delay24;

returndat;

WriteOneCharunsigned char dat //

unsigned char i0; fori8;i0;i-- DQ0; DQdat&0X01; delay25;

向DS18B20写一字节数据 DQ1; dat1; delay24;

ReadTemperaturevoid //向DS18B20读温度值

Init_DS18B20; WriteOneChar0xcc; WriteOneChar0x44; delay2125; Init_DS18B20; WriteOneChar0xcc; WriteOneChar0xbe; tempLReadOneChar; tempHReadOneChar;

temperaturetempH*256+tempL*0.0625; delay2200; returntemperature; main