--- title: while categories: [ "Structure" ] subCategories: [ "Control Structure" ] --- = while loop // OVERVIEW SECTION STARTS [#overview] -- [float] === Description [%hardbreaks] A `while` loop will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. This could be in your code, such as an incremented variable, or an external condition, such as testing a sensor. [float] === Syntax [source,arduino] ---- while (condition) { // statement(s) } ---- [float] === Parameters `condition`: a boolean expression that evaluates to `true` or `false`. -- // OVERVIEW SECTION ENDS // HOW TO USE SECTION STARTS [#howtouse] -- [float] === Example Code [source,arduino] ---- var = 0; while (var < 200) { // do something repetitive 200 times var++; } ---- -- // HOW TO USE SECTION ENDS // SEE ALSO SECTION BEGINS [#see_also] -- [float] === See also [role="language"] [role="example"] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/WhileStatementConditional[While Loop^] -- // SEE ALSO SECTION ENDS