Arduino - 将循环计数附加到int名称

时间:2016-10-20 18:11:30

标签: loops arduino

如何将循环编号[x]附加到变量名[Var]

所有[int Val]已经从之前的代码中填充。

for (int x = 1; x <= 3; x++)

   if (Val[x] > 3){

      Serial.println("Do something");

   }

}

1 个答案:

答案 0 :(得分:0)

Got my reply from the Arduino forum.

I put the values into an array then used the following code:

for (int x = 0; x < (sizeof(Val) / sizeof(Val[0])); x++) {
   if (Val [i]  > 3){
      Serial.println("Do something");
   }
}