我在试着只打一次电话。但它在一次又一次地呼唤着。代码是如果(t>20){ Sim800l.println(ATD +phone number)}我怎么才能只呼叫我一次?如果温度超过20°C,我只需要通知我,使用dht11,arduino uno和sim800l。
发布于 2021-02-22 00:49:17
你可以像这样使用一个标志。每当温度降至20以下/等于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;
}https://stackoverflow.com/questions/66304229
复制相似问题