break
break
可以不經過條件判斷即脫離 do
、for
、 while
迴圈,也可以用在 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.