arduino - while...else Arduino 声明

标签 arduino arduino-ide

是否有可能在 Arduino 中的 while-Loop 之后添加一个 else,就像在 Java 或 C# 中一样?像这样:

while(condition){
  doThingA;
} else{
  doThingB;
}

最佳答案

C# 没有 while...else 而且我认为 Java 也没有这种结构。 Python 有它,因为 else block 中的指令仅在您从循环中中断时才执行,您可以如下模拟它:

bool flag = TRUE;
while (condition)
{
    if (anothercondition)
    {
       flag = FALSE;
       break;
    }
}

if (flag)
{
    ...
}

关于arduino - while...else Arduino 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37837093/

相关文章:

arduino - 评估一个值是增加还是减少(arduino)

c - 通过串行端口读取值

ubuntu-18.04 - Arduino IDE 无法上传 Sketch (Ubuntu 18.04 LTS)

c - 丢弃距离测量中的失控值

arduino 在上次上传后突然显示 "avrdude: ser_open(): can' t 打开设备 "\\.\COM3"

algorithm - Arduino:将数据存储在EEPROM中的轻量级压缩算法

javascript - 在 while 循环中刷新来自 Leap Motion 的帧

c++ - 'void (*)(const char* )' to ' void (*)()' [-fpermissive]

c++ - 阿杜诺 | RGB LED 灯条 Controller

c++ - 在 Arduino 中除以两个整数