1

我想只打一次电话。但它一遍又一遍地呼唤。代码是 If(t>20){ Sim800l.println(ATD +电话号码)} 我怎样才能让它只给我一次电话?如果温度超过 20°C,我只需要通知我。使用 dht11、arduino uno 和 sim800l。

4

1 回答 1

0

你可以使用这样的标志。每次温度低于/等于 20 时,标志hasChanged将设置为true。并且当温度上升到 20 度以上时,将打印一次消息,并且标志将被切换到关闭,直到下次温度下降。

// you'll have to adjust the syntax to meet your language needs

bool hasChanged = true;
if (t>20 && hasChanged) {
   // this block happens once everytime the temperature surpasses 20
   Sim800l.println(ATD +phone number);
   hasChanged = false;
} else {
   hasChanged = true;
}
于 2021-02-21T16:49:17.177 回答