Init_DS18B20.c主函数- #include<reg52.h>
- #include<HL_1.h>
- #include"Init_DS18B20.h"
- int tem;//温度值
- uchar shi, ge, xiaoshu;
- uint NUM[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- uint PLACE[7] = {0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
- void main()
- {
- while(1)
- {
- start_temp_sensor();
- delay(1);
- tem = read_temp();
- shi = (int)tem/10;
- ge = (int)tem%10;
- xiaoshu = (int)(tem*10)%10;
-
- WE = 1;
- P0 = PLACE[4];
- WE = 0;
- DU = 1;
- P0 = NUM[shi];
- DU = 0;
- delay(2);
- WE = 1;
- P0 = PLACE[5];
- WE = 0;
- DU = 1;
- P0 = NUM[ge];
- DU = 0;
- delay(2);
- WE = 1;
- P0 = PLACE[5];
- WE = 0;
- DU = 1;
- P0 = 0x80;
- DU = 0;
- delay(2);
- WE = 1;
- P0 = PLACE[6];
- WE = 0;
- DU = 1;
- P0 = NUM[xiaoshu];
- DU = 0;
- delay(2);
- }
- }
|