ds18b20程序 lm386 超声波测距
writebyte(0xa0); respons(); writebyte(address); respons(); writebyte(date); respons(); stop(); void t0() interrupt 1 { uchar i; TH0=(65536-50000)/256; TL0=(65536-50000)%256; i++; if(i==20) }
uchar readbyte_add(uchar address) { uchar date; start(); writebyte(0xa0); respons(); writebyte(address); respons(); start(); writebyte(0xa1); respons(); date=readbyte(); stop(); return date; }
void main() { init(); sec=readbyte_add(2); if(sec>100) sec=0; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; ET0=1; EA=1; TR0=1; while(1) { display(sec); if(write==1) writebyte_add(2,sec); } } { } }
i=0; write=1; sec++; if(sec==100) sec=0;