while 迴圈
描述
在 while 迴圈中的程式碼會持續地執行,直到 () 中的條件式不成立。迴圈執行期間必須要改變條件式的變數值,如遞增的變數、檢查感測器等外部條件等,否則可能會無法離開 while 迴圈。
語法
while(expression){
// statement(s)
}
參數
expression – 判斷其條件成立與否
範例
var = 0;
while(var < 200){
// 持續累加 var 變數共 200 次
var++;
}
See also
- While Loop Tutorial in the Arduino Examples
本頁由熱血青年 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.
