在此之前不允许使用功能定义。{'代币

时间:2015-06-04 02:26:50

标签: arduino

我一直在使用这个简单的程序试图修复此错误的时间太长。我正在使用Arduino,我只想制作一个简单的温度监控器来打开和关闭一些开关。我一直收到错误"此处不允许使用功能定义' {'令牌&#34。如果有人比我更了解并能帮助我,那就太棒了!

float temp;

void setup(){
  pinMode(13, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(7, INPUT);
  pinMode(0, INPUT);
  Serial.begin(9600);
}

void highHeat(){
            temp = analogRead(0);
            temp = (5.0*temp*100.0/1024.0);
             if (temp > 79)
               {
                 digitalWrite(8, LOW);
                 digitalWrite(9, LOW);
                 digitalWrite(10, LOW);
                 digitalWrite(11, LOW);
                 digitalWrite(13, LOW);
               }

             if (temp < 78)
               {
                 digitalWrite(8, HIGH);
                 digitalWrite(9, HIGH);
                 digitalWrite(10, HIGH);
                 digitalWrite(11, HIGH);
                 digitalWrite(13, HIGH);
               }
             delay(10000);
}

void lowHeat(){
            temp = analogRead(0);
            temp = (5.0*temp*100.0/1024.0);
             if (temp > 26)
               {
                 digitalWrite(8, LOW);
                 digitalWrite(9, LOW);
                 digitalWrite(10, LOW);
                 digitalWrite(11, LOW);
                 digitalWrite(13, LOW);
               }

             if (temp < 25)
               {
                 digitalWrite(8, HIGH);
                 digitalWrite(9, HIGH);
                 digitalWrite(10, HIGH);
                 digitalWrite(11, HIGH);
                 digitalWrite(13, HIGH);
               }
             delay(10000);
}

void loop(){
  if (6 == HIGH)
    {
      delay(2000);
      if (6 == HIGH)
        {
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          delay(500);
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          delay(500);
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          delay(500);
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          void loop(){
            lowHeat();
          }
        }

      if (6 == LOW)
        {
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          delay(500);
          digitalWrite(13, HIGH);
          delay(500);
          digitalWrite(13, LOW);
          void loop(){
            highHeat();
          }
        }
    }
}

P.S。我做了一些搜索,发现很多帖子都有相同的标题,但它们似乎从来没有与我的问题相关,所以我只是觉得我会请求一点帮助。

1 个答案:

答案 0 :(得分:2)

你有:

      digitalWrite(13, LOW);
      void loop(){
        lowHeat();
      }

编译器在抱怨void loop()。您无法在另一个函数的中间定义函数。