这是我自己写的SHT10 的程序,SHT1X 系列的都适用。 几点说明: 1.主要是分以下几个模块写的:SHT10,LCD1602,主函数,头文件。 2.每支SHTxx 传感器都在25℃(77 °F)和 3.3V 条件下进行过标定并且完全符合精度指标.因为考虑到实际硬件5V 的电压比较好操作,所以SHT10 用的精度采用的为 5V 时的参数。其他的都采取默认值(14bit 湿度 , 12bit 温度)。 3.SHT10 中所以部分我都编写了。有的部分在本次程序中没用到,也可以作为参考。 4.所有程序都已经加了注释,且有仿真图。 5.个人认为还可以在此基础上添加个中断。 6.程序编写keil 4 ,仿真 protues7.5 /***********************************************************************************************************************************************************/ 头文件(tou.h): #ifndef __TOU_H__ #define __TOU_H__ #include #include //#include //Keil library #define uchar unsigned char enum {TEMP,HUMI}; sbit DATA = P1^7; sbit SCK = P1^6; sbit LcdRs = P2^4; sbit LcdRw = P2^5; sbit LcdEn = P2^6; sfr DBPort = 0x80; //P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口 /******** DS1602 函数声明 ********/ void LCD_Initial(); void GotoXY(unsigned char x, unsigned char y); void Print(unsigned char *str); void LCD_Write(bit style, unsigned char input); /******** SHT10 函数声明 ********/ void s_connectionreset(void); char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode); void calc_sth10(float *p_humidity ,float *p_temperature); //float calc_dewpoint(float h,float t); #endif /***********************************************************************************************************************************************************/ SHT10 程序(SHT10.c): #include #define noACK 0 //继续传输数据,用于判断是否结束通讯 #define ACK 1 //结束数据传输; //地址 命令 读/写 #define STATUS_REG_W 0x06 //000 0011 0 #define STATUS_REG_R 0x07 //000 0011 1 #define MEASURE_TEMP 0x03 //0...