找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2026|回复: 3
打印 上一主题 下一主题
收起左侧

基于单片机的仓库温湿度源程序错误有大神帮忙改么

[复制链接]
跳转到指定楼层
楼主
ID:325334 发表于 2018-5-8 20:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
200黑币
本人用的是keil4,源程序如下:
  1. #include<reg51.h>
  2. #include"key_contrl.h"
  3. #include"lcd1602.h"
  4. #define LCM_Data P1
  5. #define Busy 0x80 //用于检测LCM状态字中的Busy标识
  6. extern int temp_value,humi_value;
  7. extern int flag;
  8. extern int temp;
  9. sbit red=P2^6;
  10. sbit blue=P2^7;
  11. sbit LCM_RW= P2^4; //定义引脚
  12. sbit LCM_RS= P2^5;
  13. sbit LCM_E= P2^3;
  14. sbit beep = P0^6;//beep = 0时候发声
  15. extern inttemph,templ,disp_mode,huih,huil;
  16. extern chartel,teh,hh,hl;
  17. //写数据
  18. void alarm()
  19. {
  20.        beep=0;
  21.        Delay5Ms();
  22.        Delay5Ms();
  23.        beep=1;
  24.        Delay5Ms();
  25.        Delay5Ms();
  26. }
  27. voidWriteDataLCM(unsigned char WDLCM)
  28. {
  29. ReadStatusLCM(); //检测忙
  30. LCM_Data = WDLCM;
  31. LCM_RS = 1;
  32. LCM_RW = 0;
  33. LCM_E = 0; //若晶振速度太高可以在这后加小的延时
  34. LCM_E = 0; //延时
  35. LCM_E = 1;
  36. }
  37. //写指令
  38. voidWriteCommandLCM(unsigned char WCLCM,BuysC) //BuysC为0时忽略忙检测
  39. {
  40. if (BuysC)ReadStatusLCM(); //根据需要检测忙
  41. LCM_Data = WCLCM;
  42. LCM_RS = 0;
  43. LCM_RW = 0;
  44. LCM_E = 0;
  45. LCM_E = 0;
  46. LCM_E = 1;
  47. }
  48. //读数据
  49. unsigned charReadDataLCM(void)
  50. {
  51. LCM_RS = 1;
  52. LCM_RW = 1;
  53. LCM_E = 0;
  54. LCM_E = 0;
  55. LCM_E = 1;
  56. return(LCM_Data);
  57. }
  58. //读状态
  59. unsigned charReadStatusLCM(void)
  60. {
  61. LCM_Data = 0xFF;
  62. LCM_RS = 0;
  63. LCM_RW = 1;
  64. LCM_E = 0;
  65. LCM_E = 0;
  66. LCM_E = 1;
  67. while (LCM_Data &Busy); //检测忙信号
  68. return(LCM_Data);
  69. }
  70. void LCMInit(void)//LCM初始化
  71. {
  72. LCM_Data = 0;
  73. WriteCommandLCM(0x38,0);//三次显示模式设置,不检测忙信号
  74. Delay5Ms();
  75. WriteCommandLCM(0x38,0);
  76. Delay5Ms();
  77. WriteCommandLCM(0x38,0);
  78. Delay5Ms();
  79. WriteCommandLCM(0x38,1);//显示模式设置,开始要求每次检测忙信号
  80. WriteCommandLCM(0x08,1);//关闭显示
  81. WriteCommandLCM(0x01,1);//显示清屏
  82. WriteCommandLCM(0x06,1);// 显示光标移动设置
  83. WriteCommandLCM(0x0C,1);// 显示开及光标设置
  84. }
  85. //按指定位置显示一个字符
  86. voidDisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
  87. {
  88. Y &= 0x1;
  89. X &= 0xF; //限制X不能大于15,Y不能大于1
  90. if (Y) X |= 0x40; //当要显示第二行时地址码 0x40;
  91. X |= 0x80; // 算出指令码
  92. WriteCommandLCM(X, 0);//这里不检测忙信号,发送地址码
  93. WriteDataLCM(DData);
  94. }
  95. //按指定位置显示一串字符
  96. voidDisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
  97. {
  98. unsigned charListLength;
  99. ListLength = 0;
  100. Y &= 0x1;
  101. X &= 0xF; //限制X不能大于15,Y不能大于1
  102. while(DData[ListLength]>0x20) //若到达字串尾则退出
  103. {
  104. if (X <= 0xF) //X坐标应小于0xF
  105. {
  106. DisplayOneChar(X, Y,DData[ListLength]); //显示单个字符
  107. ListLength++;
  108. X++;
  109. }
  110. }
  111. }
  112. //5ms延时
  113. void Delay5Ms(void)
  114. {
  115. unsigned int TempCyc =5552;
  116. while(TempCyc--);
  117. }
  118. /*voidDelay_xMs(unsigned int x)
  119. {
  120.     unsigned int i,j;
  121.     for( i =0;i < x;i++ )
  122.     {
  123.         for( j =0;j<500;j++ );
  124.     }
  125. }
  126. */
  127. void display_temp(void)
  128. {
  129.        DisplayOneChar(0,0,' ');
  130.        DisplayOneChar(1,0,' ');
  131.        DisplayOneChar(2,0,'T');
  132.        DisplayOneChar(3,0,'e');
  133.        DisplayOneChar(4,0,'m');
  134.        DisplayOneChar(5,0,'p');
  135.        DisplayOneChar(6,0,':');
  136.        DisplayOneChar(10,0,'C');
  137.        DisplayOneChar(9,0,0xdf);
  138.        DisplayOneChar(7,0,temp_value/100+0x30);
  139.        DisplayOneChar(8,0,(temp_value/10)-(temp_value/100)*10+0x30);
  140.        DisplayOneChar(11,0,' ');
  141.        DisplayOneChar(12,0,' ');
  142.        DisplayOneChar(13,0,' ');
  143.        DisplayOneChar(14,0,' ');
  144.        DisplayOneChar(15,0,' ');
  145.        DisplayOneChar(0,1,' ');
  146.        DisplayOneChar(1,1,' ');
  147.        DisplayOneChar(2,1,'H');
  148.        DisplayOneChar(3,1,'u');
  149.        DisplayOneChar(4,1,'m');
  150.        DisplayOneChar(5,1,'i');
  151.        DisplayOneChar(6,1,'d');
  152.        DisplayOneChar(7,1,'i');
  153.        DisplayOneChar(8,1,'t');
  154.               DisplayOneChar(9,1,'y');
  155.        DisplayOneChar(10,1,':');
  156.        DisplayOneChar(11,1,humi_value/100+0x30);
  157.        DisplayOneChar(12,1,(humi_value/10)-(humi_value/100)*10+0x30);
  158.        DisplayOneChar(13,1,'%');
  159.        DisplayOneChar(14,1,' ');
  160.        DisplayOneChar(15,1,' ');
  161. }     
  162. voiddisplay_temp1(void)
  163. {
  164.        DisplayOneChar(0,0,' ');
  165.        DisplayOneChar(1,0,'T');
  166.        DisplayOneChar(2,0,'h');
  167.        DisplayOneChar(3,0,':');
  168.        if(flag&teh)
  169.        {
  170.        DisplayOneChar(4,0,0x20);
  171.        DisplayOneChar(5,0,0x20);
  172.        }
  173.        else
  174.        {
  175.        DisplayOneChar(4,0,temph/10+0x30);
  176.        DisplayOneChar(5,0,temph%10+0x30);
  177.        }
  178.        DisplayOneChar(6,0,0xdf);
  179.        DisplayOneChar(7,0,'C');
  180.        DisplayOneChar(8,0,' ');
  181.        DisplayOneChar(9,0,'T');
  182.        DisplayOneChar(10,0,'h');
  183.        DisplayOneChar(11,0,':');
  184.        if(flag&tel)
  185.        {
  186.        DisplayOneChar(12,0,0x20);
  187.        DisplayOneChar(13,0,0x20);
  188.        }
  189.        else
  190.        {
  191.        DisplayOneChar(12,0,templ/10+0x30);
  192.        DisplayOneChar(13,0,templ%10+0x30);
  193.        }
  194.        DisplayOneChar(14,0,0xdf);
  195.        DisplayOneChar(15,0,'C');
  196.               DisplayOneChar(0,1,' ');
  197.        DisplayOneChar(1,1,'H');
  198.        DisplayOneChar(2,1,'h');
  199.        DisplayOneChar(3,1,':');
  200.               if(flag&hh)
  201.        {
  202.        DisplayOneChar(4,1,0x20);
  203.        DisplayOneChar(5,1,0x20);
  204.        }
  205.        else
  206.        {
  207.        DisplayOneChar(4,1,huih/10+0x30);
  208.        DisplayOneChar(5,1,huih%10+0x30);
  209.        }
  210.        DisplayOneChar(6,1,'%');
  211.        DisplayOneChar(7,1,' ');
  212.        DisplayOneChar(8,1,' ');
  213.        DisplayOneChar(9,1,'H');
  214.        DisplayOneChar(10,1,'l');
  215.        DisplayOneChar(11,1,':');
  216.               if(flag&hl)
  217.        {
  218.        DisplayOneChar(12,1,0x20);
  219.        DisplayOneChar(13,1,0x20);
  220.        }
  221.        else
  222.        {
  223.        DisplayOneChar(12,1,huil/10+0x30);
  224.        DisplayOneChar(13,1,huil%10+0x30);
  225.        }
  226.        DisplayOneChar(14,1,'%');
  227.        DisplayOneChar(15,1,' ');
  228. }     
  229. void displayfun1()
  230. {
  231.        display_temp();
  232. }
  233. void displayfun2()
  234. {
  235.        display_temp1();      
  236. }
  237. void display()
  238. {
  239.               if((((temp_value/10)%100)<templ)||(((humi_value/10)%100)<huil))
  240.               {beep=0;red=0;}                //温度低于下限值,报警
  241.              elseif(((temp_value/10)%100)>=temph || ((humi_value/10)%100)>=huih)
  242.                      {beep=0;blue=0;}      //温度高于或等于上限值,报警
  243.              else{beep=1;red=1;blue=1;}
  244. //            if(((humi_value/10)%100)<huil){beep=0;led=0;}               //温度低于下限值,报警
  245. //          elseif(((humi_value/10)%100)>=huih)beep=0;     //温度高于或等于上限值,报警
  246. //          else{beep=1;led=1;}
  247.         if(!disp_mode)
  248.              displayfun1(); //显示正常
  249.         else
  250.               displayfun2(); //设置界面
  251. }
  252. #include"dht11.h"
  253. #include<reg52.h>
  254. //请根据自己的dht11接的IO 口来改动位定义
  255. sbit dht11 = P3^0;
  256. //防止在与硬件通信时发生死循环的计数范围
  257. #define NUMBER 20
  258. #define SIZE 5
  259. static unsigned charstatus;
  260. //存放五字节数据的数组
  261. static unsigned charvalue_array[SIZE];
  262. /*可在其他的文件引用温湿度值,实际是温度的整数的10 倍
  263. 如dht11 读回的温度是26,则temp_value = 260, 湿度同理*/
  264. int temp_value,humi_value;
  265. static unsigned charReadValue(void);
  266. void Delay_1ms(unsignedint ms)
  267. {
  268.        unsigned int x, y;
  269.        for(x = ms; x > 0; x--)
  270.        {
  271.               for(y = 124; y > 0; y--);
  272.        }
  273. }
  274. static voidDHT11_Delay_10us(void)
  275. {
  276.        unsigned char i;
  277.        i--;
  278.        i--;
  279.        i--;
  280.        i--;
  281.        i--;
  282.        i--;
  283. }
  284. /*读一个字节的数据*/
  285. static unsigned charDHT11_ReadValue(void)
  286. {
  287.        unsigned char count, value = 0, i;
  288.        status = OK; //设定标志为正常状态
  289.        for(i = 8; i > 0; i--)
  290.        {
  291.               //高位在先
  292.               value <<= 1;
  293.               count = 0;
  294.               //每一位数据前会有一个50us 的低电平时间.等待50us低电平结束
  295.               while(dht11 == 0 && count++ < NUMBER);
  296.               if(count >= NUMBER)
  297.                      {
  298.                      status = ERROR; //设定错误标志
  299.                      return 0; //函数执行过程发生错误就退出函数
  300.                      }
  301.               //26-28us 的高电平表示该位是0,为70us高电平表该位1
  302.               DHT11_Delay_10us();
  303.               DHT11_Delay_10us();
  304.               DHT11_Delay_10us();
  305.               //延时30us 后检测数据线是否还是高电平
  306.               if(dht11 != 0)
  307.               {
  308.               //进入这里表示该位是1
  309.                      value++;
  310.               //等待剩余(约40us)的高电平结束
  311.                      while(dht11 != 0 && count++ < NUMBER)
  312.                      {
  313.                             dht11 = 1;
  314.                      }
  315.                      if(count >= NUMBER)
  316.                      {
  317.                             status = ERROR; //设定错误标志
  318.                             return 0;
  319.                      }
  320.               }
  321.        }
  322.        return (value);
  323. }
  324. //读温度和湿度函数,读一次的数据,共五字节,读出成功函数返回OK, 错误返回ERROR
  325. unsigned charDHT11_ReadTempAndHumi(void)
  326. {
  327.        unsigned char i = 0, check_value = 0,count = 0;
  328.        EA = 0;
  329.        dht11 = 0; //拉低数据线大于18ms 发送开始信号
  330.        Delay_1ms(20); //需大于18 毫秒
  331.        dht11 = 1; //释放数据线,用于检测低电平的应答信号
  332.        //延时20-40us,等待一段时间后检测应答信号,应答信号是从机拉低数据线80us
  333.        DHT11_Delay_10us();
  334.        DHT11_Delay_10us();
  335.        DHT11_Delay_10us();
  336.        DHT11_Delay_10us();
  337.        if(dht11 != 0) //检测应答信号,应答信号是低电平
  338.        {
  339.               //没应答信号
  340.               EA = 1;
  341.               return ERROR;
  342.        }
  343.        else
  344.        {
  345.               //有应答信号
  346.               while(dht11 == 0 && count++ < NUMBER); //等待应答信号结束
  347.               if(count >= NUMBER) //检测计数器是否超过了设定的范围
  348.               {
  349.                      dht11 = 1;
  350.                      EA = 1;
  351.                      return ERROR; //读数据出错,退出函数
  352.               }
  353.               count = 0;
  354.               dht11 = 1;//释放数据线
  355.               //应答信号后会有一个80us 的高电平,等待高电平结束
  356.               while(dht11 != 0 && count++ < NUMBER);
  357.               if(count >= NUMBER)
  358.               {
  359.                      dht11 = 1;
  360.                      EA = 1;
  361.                      return ERROR; //退出函数
  362.               }
  363.               //读出湿.温度值
  364.               for(i = 0; i < SIZE; i++)
  365.               {
  366.                      value_array[ i] = DHT11_ReadValue();
  367.                      if(status == ERROR)//调用ReadValue()读数据出错会设定status 为ERROR
  368.                      {
  369.                             dht11 = 1;
  370.                             EA = 1;
  371.                             return ERROR;
  372.                      }
  373.                      //读出的最后一个值是校验值不需加上去
  374.                      if(i != SIZE - 1)
  375.                      {
  376.                             //读出的五字节数据中的前四字节数据和等于第五字节数据表示成功
  377.                             check_value += value_array[ i];
  378.                      }
  379.               }//end for
  380.                      //在没用发生函数调用失败时进行校验
  381.               if(check_value == value_array[SIZE - 1])
  382.               {
  383.                      //将温湿度扩大10 倍方便分离出每一位
  384.                      humi_value = value_array[0] * 10;
  385.                      temp_value = value_array[2] * 10;
  386.                      dht11 = 1;
  387.                      EA = 1;
  388.                      return OK; //正确的读出dht11 输出的数据
  389.               }
  390.               else
  391.               {
  392.                      //校验数据出错
  393.                      EA = 1;
  394.                      return ERROR;
  395.               }
  396.        }
  397. }
  398. #include"lcd1602.h"

  399. #include"key_contrl.h"
  400. #include"dht11.h"


  401. #include<reg52.h>


  402. int temp;

  403. int temph = 40;                    //初始上限值
  404. int templ = 10;                                     //初始下限值
  405. int huih = 90;
  406. int huil =10;

  407. inttimecount,flag=0,number=0,count=0;



  408. void t0(void) interrupt1 using 0   
  409. {   TH0=(65535-50000)/256; //50ms定时
  410.      TL0=(65535-50000)%256;  
  411.      timecount++;//re_disp++;
  412.      if(timecount>9){timecount=0;flag=~flag;}                             //50ms到了则反显
  413.        //if(re_disp>200){re_disp=0;if(id)id=0;}  //10秒到了则由调整模式自动进入正常显示模式
  414. }

  415. void t1(void) interrupt 3 using 0
  416. {
  417.        TH1=(65535-50000)/256;//50ms定时
  418.        TL1=(65535-50000)%256;
  419.        number++;
  420.        if(number>2)
  421.        {
  422.               number=0;
  423.               count++;

  424.               //beep=0;
  425.        }
  426. }


  427. void main(void)
  428. {
  429.               TMOD=0x11;                                 //初始化定时器t0方式1
  430.             TH0=(65535-50000)/256;
  431.             TL0=(65535-50000)%256;
  432.               TH1=(65535-50000)/256;
  433.               TL1=(65535-50000)%256;     

  434.             EA=1;
  435.             ET0=1;

  436.          ET1=1;
  437.               TR0=1;
  438.              TR1=1;
  439.               LCMInit(); //LCM初始化
  440.               Delay5Ms(); //延时片刻
  441.               

  442.        while(1)
  443.        {
  444.               if(count==2)
  445.                      {
  446.                             DHT11_ReadTempAndHumi();
  447.                             count=0;
  448.                      }
  449.               delay_LCM(300);
  450.               Scan_Key();
  451.        }
  452.       
  453. }
复制代码


这里是出现的各种各样的问题
Build target '目标 1'
compiling 1.c...
1.c(3): warning C318: can't open file 'key_contrl.h'
1.c(4): warning C318: can't open file 'lcd1602.h'
1.C(34): warning C206: 'Delay5Ms': missing function-prototype
1.C(46): warning C206: 'ReadStatusLCM': missing function-prototype
1.C(77): error C231: 'ReadStatusLCM': redefinition
1.C(86): error C231: 'ReadStatusLCM': redefinition
1.C(131): error C231: 'Delay5Ms': redefinition
1.C(134): error C231: 'Delay5Ms': redefinition
1.c(296): warning C318: can't open file 'dht11.h'
D:\秃驴爹\C51\INC\REG52.H(13): error C231: 'P0': redefinition
D:\秃驴爹\C51\INC\REG52.H(14): error C231: 'P1': redefinition
D:\秃驴爹\C51\INC\REG52.H(15): error C231: 'P2': redefinition
D:\秃驴爹\C51\INC\REG52.H(16): error C231: 'P3': redefinition
D:\秃驴爹\C51\INC\REG52.H(17): error C231: 'PSW': redefinition
D:\秃驴爹\C51\INC\REG52.H(18): error C231: 'ACC': redefinition
D:\秃驴爹\C51\INC\REG52.H(19): error C231: 'B': redefinition
D:\秃驴爹\C51\INC\REG52.H(20): error C231: 'SP': redefinition
D:\秃驴爹\C51\INC\REG52.H(21): error C231: 'DPL': redefinition
D:\秃驴爹\C51\INC\REG52.H(22): error C231: 'DPH': redefinition
D:\秃驴爹\C51\INC\REG52.H(23): error C231: 'PCON': redefinition
D:\秃驴爹\C51\INC\REG52.H(24): error C231: 'TCON': redefinition
D:\秃驴爹\C51\INC\REG52.H(25): error C231: 'TMOD': redefinition
D:\秃驴爹\C51\INC\REG52.H(26): error C231: 'TL0': redefinition
D:\秃驴爹\C51\INC\REG52.H(27): error C231: 'TL1': redefinition
D:\秃驴爹\C51\INC\REG52.H(28): error C231: 'TH0': redefinition
D:\秃驴爹\C51\INC\REG52.H(29): error C231: 'TH1': redefinition
D:\秃驴爹\C51\INC\REG52.H(30): error C231: 'IE': redefinition
D:\秃驴爹\C51\INC\REG52.H(31): error C231: 'IP': redefinition
D:\秃驴爹\C51\INC\REG52.H(32): error C231: 'SCON': redefinition
D:\秃驴爹\C51\INC\REG52.H(33): error C231: 'SBUF': redefinition
D:\秃驴爹\C51\INC\REG52.H(45): error C231: 'CY': redefinition
D:\秃驴爹\C51\INC\REG52.H(46): error C231: 'AC': redefinition
D:\秃驴爹\C51\INC\REG52.H(47): error C231: 'F0': redefinition
D:\秃驴爹\C51\INC\REG52.H(48): error C231: 'RS1': redefinition
D:\秃驴爹\C51\INC\REG52.H(49): error C231: 'RS0': redefinition
D:\秃驴爹\C51\INC\REG52.H(50): error C231: 'OV': redefinition
D:\秃驴爹\C51\INC\REG52.H(51): error C231: 'P': redefinition
D:\秃驴爹\C51\INC\REG52.H(54): error C231: 'TF1': redefinition
D:\秃驴爹\C51\INC\REG52.H(55): error C231: 'TR1': redefinition
D:\秃驴爹\C51\INC\REG52.H(56): error C231: 'TF0': redefinition
D:\秃驴爹\C51\INC\REG52.H(57): error C231: 'TR0': redefinition
D:\秃驴爹\C51\INC\REG52.H(58): error C231: 'IE1': redefinition
D:\秃驴爹\C51\INC\REG52.H(59): error C231: 'IT1': redefinition
D:\秃驴爹\C51\INC\REG52.H(60): error C231: 'IE0': redefinition
D:\秃驴爹\C51\INC\REG52.H(61): error C231: 'IT0': redefinition
D:\秃驴爹\C51\INC\REG52.H(64): error C231: 'EA': redefinition
D:\秃驴爹\C51\INC\REG52.H(66): error C231: 'ES': redefinition
D:\秃驴爹\C51\INC\REG52.H(67): error C231: 'ET1': redefinition
D:\秃驴爹\C51\INC\REG52.H(68): error C231: 'EX1': redefinition
D:\秃驴爹\C51\INC\REG52.H(69): error C231: 'ET0': redefinition
D:\秃驴爹\C51\INC\REG52.H(70): error C231: 'EX0': redefinition
D:\秃驴爹\C51\INC\REG52.H(74): error C231: 'PS': redefinition
D:\秃驴爹\C51\INC\REG52.H(75): error C231: 'PT1': redefinition
D:\秃驴爹\C51\INC\REG52.H(76): error C231: 'PX1': redefinition
D:\秃驴爹\C51\INC\REG52.H(77): error C231: 'PT0': redefinition
D:\秃驴爹\C51\INC\REG52.H(78): error C231: 'PX0': redefinition
D:\秃驴爹\C51\INC\REG52.H(81): error C231: 'RD': redefinition
D:\秃驴爹\C51\INC\REG52.H(82): error C231: 'WR': redefinition
D:\秃驴爹\C51\INC\REG52.H(83): error C231: 'T1': redefinition
D:\秃驴爹\C51\INC\REG52.H(84): error C231: 'T0': redefinition
D:\秃驴爹\C51\INC\REG52.H(85): error C231: 'INT1': redefinition
D:\秃驴爹\C51\INC\REG52.H(86): error C231: 'INT0': redefinition
D:\秃驴爹\C51\INC\REG52.H(87): error C231: 'TXD': redefinition
D:\秃驴爹\C51\INC\REG52.H(88): error C231: 'RXD': redefinition
D:\秃驴爹\C51\INC\REG52.H(91): error C231: 'SM0': redefinition
D:\秃驴爹\C51\INC\REG52.H(92): error C231: 'SM1': redefinition
D:\秃驴爹\C51\INC\REG52.H(93): error C231: 'SM2': redefinition
D:\秃驴爹\C51\INC\REG52.H(94): error C231: 'REN': redefinition
D:\秃驴爹\C51\INC\REG52.H(95): error C231: 'TB8': redefinition
D:\秃驴爹\C51\INC\REG52.H(96): error C231: 'RB8': redefinition
D:\秃驴爹\C51\INC\REG52.H(97): error C231: 'TI': redefinition
D:\秃驴爹\C51\INC\REG52.H(98): error C231: 'RI': redefinition
1.C(345): error C202: 'OK': undefined identifier
1.C(355): error C202: 'ERROR': undefined identifier
1.C(374): error C202: 'ERROR': undefined identifier
1.C(398): error C202: 'ERROR': undefined identifier
1.C(408): error C202: 'ERROR': undefined identifier
1.C(418): error C202: 'ERROR': undefined identifier
1.C(424): error C202: 'ERROR': undefined identifier
1.C(428): error C202: 'ERROR': undefined identifier
1.C(445): error C202: 'OK': undefined identifier
1.C(451): error C202: 'ERROR': undefined identifier
1.c(455): warning C318: can't open file 'lcd1602.h'
1.c(457): warning C318: can't open file 'key_contrl.h'
1.c(458): warning C318: can't open file 'dht11.h'
目标未创建

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:325334 发表于 2018-5-8 20:04 | 只看该作者
刚刚入门的楼主 希望大家给予详细解答
回复

使用道具 举报

板凳
ID:269211 发表于 2018-5-10 10:37 | 只看该作者
你这里不是没有把头文件放在工程的文件夹里?你的主函数用了#include<reg51.h>,你的头文件应该是用了#include<reg52.h>。所以肯定有很多错误了,你再修改一下。你还有一些函数没定义,仔细查一下。
回复

使用道具 举报

地板
ID:325334 发表于 2018-5-10 18:27 | 只看该作者
这里是改完以后出现的问题,请问该怎么修改
1.c(3): warning C318: can't open file 'key_contrl.h'
1.c(4): warning C318: can't open file 'lcd1602.h'
1.C(34): warning C206: 'Delay5Ms': missing function-prototype
1.C(46): warning C206: 'ReadStatusLCM': missing function-prototype
1.C(131): error C231: 'Delay5Ms': redefinition
1.C(134): error C231: 'Delay5Ms': redefinition
1.c(296): warning C318: can't open file 'dht11.h'
1.C(345): error C202: 'OK': undefined identifier
1.C(355): error C202: 'ERROR': undefined identifier
1.C(374): error C202: 'ERROR': undefined identifier
1.C(398): error C202: 'ERROR': undefined identifier
1.C(408): error C202: 'ERROR': undefined identifier
1.C(418): error C202: 'ERROR': undefined identifier
1.C(424): error C202: 'ERROR': undefined identifier
1.C(428): error C202: 'ERROR': undefined identifier
1.C(445): error C202: 'OK': undefined identifier
1.C(451): error C202: 'ERROR': undefined identifier
1.c(455): warning C318: can't open file 'lcd1602.h'
1.c(457): warning C318: can't open file 'key_contrl.h'
1.c(458): warning C318: can't open file 'dht11.h'
1.c - 12 Error(s), 8 Warning(s).
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表