[Control Structures]
説明
break は、通常のループ条件をバイパスして、for、while、または do…while ループを終了するために使用されます。また、switch case ステートメントを終了するためにも使用されます。
例
In the following code, the control exits the for loop when the sensor value exceeds the threshold.
int threshold = 40;
for (int x = 0; x < 255; x++) {
analogWrite(PWMpin, x);
sens = analogRead(sensorPin);
if (sens > threshold) { // bail out on sensor detect
x = 0;
break;
}
delay(50);
}Language Reference Home
86Duinoリファレンスのテキストは、Arduinoリファレンスを改変したもので、Creative Commons Attribution-ShareAlike 3.0ライセンスに基づいてライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。