break

break 可以不经过条件判断即脱离 doforwhile 回圈,也可以用在 switch 的脱离。

范例

for (x = 0; x < 255; x ++)
{
    digitalWrite(PWMpin, x);
    sens = analogRead(sensorPin);  
    if (sens > threshold){      // 结束感测器检测
      x = 0;
      break;
    }  
    delay(50);
}

语法参考主页面

本页由热血青年 LBU 译自英文版。

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.