Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 4469|回復: 1

a function-definition is not allowed here before '{' token" error

[複製鏈接]
發表於 2020-12-11 21:10:16 | 顯示全部樓層 |閱讀模式
請問我的程式裡括號的部分是錯在哪呢,一直找不到答案......
可以幫忙修改嗎

#include <DHT.h>

#include <DHT_U.h>



void setup()
{
#include" DHT.h "
#define dhtPin 2 //Read DHT11 data
#define dhtType DHT11 // //Insert DHT11
#define FAN 8
#define HOT 9
#define PERIOD1 10 * 60 * 60 * 1000 //in a few units
#define PERIOD2 15 * 60 * 60 * 1000 //in millimeters
#define PERIOD3 25 * 60 * 60 * 1000
  // millis() returns unsigned long, so we will use it to track
  Unsigned longer lastTime = 0;
  / *
  Temperature control program
  Maintain 80 degrees for 10 minutes
  Maintain 70 degrees for 15 minutes
    Maintain 60 degrees in 25 minutes
    * /
    DHT dht (dhtPin, dhtType); //Initialize DHT sensor
  int stage = 0;
  Floating point t
  void setup()
  {
    Serial.begin(9600);//Set the baud rate to 9600
    pinMode (FAN, OUTPUT);
    pinMode (heat, output);
    digitalWrite(FAN, LOW);
    digitalWrite(HOT, LOW);
    dht.begin(); //Start DHT
    lastTime = millis();
    Stage = 80;
  }
  void up()
  {
    if (stage >= t - 3)
    {
      digitalWrite(FAN, HIGH);
      digitalWrite(HOT, LOW);
    }
    Otherwise (stage <= t - 3)
    {
      digitalWrite(FAN, HIGH);
      digitalWrite(HOT, LOW);
    }
    other
    {

      digitalWrite(FAN, LOW);

      digitalWrite(HOT, LOW);

    }
  }
  Invalid loop()
  {
    t = dht.readTemperature();//Read the temperature in Celsius
    float f = dht.readTemperature(true);//Whether read the temperature in Fahrenheit
    (Isnan(h) || isnan(t) || isnan(f))
    {
      Serial.println("Unable to read from DHT sensor!");
      return;
    }
    unsigned long now = millis();
    if (now - lastTime >= PERIOD1) //every PERIOD count
    {
      Stage = 80;
    }
    Otherwise if (now - lastTime >= PERIOD2) //every PERIOD count is once
    {
      Stage = 70;
    }
    else if (now - lastTime >= PERIOD3) //every PERIOD count
    {
      Stage = 60;
    }
  }
}

點評

海!外直播 cutt.us/q33 禁闻视频 v.ht/fccc 记者:暴雨村里有房子有倒的吗?老乡:没倒塌,拆迁办比洪水来得早。记者:地里庄稼被冲了吧? 老乡:真的没有!开发商也比洪水来得早,地早征走了。   發表於 2021-9-7 10:06
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2021-10-28 13:52 , Processed in 0.128465 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表