错误都用红 {MOD}注明了
#include<reg52.h>
#include"SHT.h"
chengxu.c(2): warning C318: can't open file 'SHT.h'
#include"lcd1602.h"
chengxu.c(3): warning C318: can't open file 'lcd1602.h'
unsigned char table[]="luyao";
unsigned char shtdatah,shtdatal;
unsigned long shtdata;
void jisuan_humidity(void)
{
unsigned long aa,bb;
shtdatah&=0x0f;
aa=(unsigned long)(shtdatah*256+shtdatal);
bb=aa;
aa=405*aa;
aa/=100;
bb=bb*bb;
bb=28*bb;
bb/=100000;
shtdata=aa-400-bb;
}
void jisuan_temp(void)
{
unsigned long aa;
shtdatah&=0x3f;
aa=(unsigned long)(shtdatah*256+shtdatal);
shtdata=aa-4000;
}
void sht_all(void)
{
unsigned int j;
read_temp();
chengxu.c(30): warning C206: 'read_temp': missing function-prototype
jisuan_temp();
j=3;
if(shtdata/10000==0) {lcd_display(1,3,' ');}
else{ lcd_display(1,j,0x30+shtdata/10000);j++;}
lcd_display(1,j++,0x30+(shtdata/1000)%10);
lcd_display(1,j++,0x30+(shtdata/100)%10);
lcd_display(1,j++,0x30+(shtdata/10)%10);
lcd_display(1,j++,0x30+(shtdata%10));
read_humidity();
jisuan_humidity();
j=11;
if(shtdata/10000==0) lcd_display(1,11,' ');
chengxu.c(33): warning C206: 'lcd_display': missing function-prototype
chengxu.c(33): error C267: 'lcd_display': requires ANSI-style prototype
else lcd_display(1,j++,0x30+shtdata/10000);
lcd_display(1,j++,0x30+(shtdata/1000)%10);
lcd_display(1,j++,0x30+(shtdata/100)%10);
lcd_display(1,j++,0x30+(shtdata/10)%10);
lcd_display(1,j++,0x30+(shtdata%10));
}
void main(void)
{
unsigned char i;
lcd_init();
sht_init();
lcd_display(1,1,'T');
lcd_display(1,2,':');
lcd_display(1,9,'H');
lcd_display(1,10,':');
for(i=0;i<8;i++)
lcd_display(2,i+1,table);
lcd_display(2,12,'S');
lcd_display(2,13,'H');
lcd_display(2,14,'T');
lcd_display(2,15,0X31);
lcd_display(2,16,0X31);
while(1)
{
delay(100);
sht_all();
delay(100);
}
}
#ifndef _lcd1602_h
#define _lcd1602_h
#include<reg52.h>
sbit lcde=P2^0;
sbit lcdrs=P2^1;
void delay(unsigned int z);
void write_com(unsigned char cdate);
void write_date(unsigned char date);
void lcd_init(void); void lcd_display(unsigned char x,unsigned char y,unsigned char date);
#endif
#ifndef _sht_h
#define _sht_h
#include<reg52.h>
sbit SHT_sck=P2^6;
sbit SHT_data=P2^7;
extern unsigned char shtdatah,shtdatal;
void delay_nms(unsigned int z);
void SHT_start(void);
void write_sht_byte(unsigned char sdata);
void write_sht_command(unsigned char cmd);
void sht_rst(void);
void read_sht(void);
void sht_init(void);
void read_temp(void);
void read_humidity(void);
#endif
一周热门 更多>