Skip to content

Commit 7c20a13

Browse files
authored
Update while.adoc
None of the While or While Loop explanations or tutorials make it entirely clear how the loop ends or what happens when it does end, and I've puzzled over this for some time. Also, some comparison is needed between If, While, Do While, and For to clarify what each is best for and when best to use them. Also, NONE of these While explanations or tutorials mentions that you can use <break> to get out of them early. An example using Break would be good on this page, too, such as using a sensor reading to interrupt the While before it's finished. Let's say, while a switch is open, keep running a motor until the switch closes. Can do this with If statement, how is while better?
1 parent bd73a13 commit 7c20a13

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Language/Structure/Control Structure/while.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ while (var < 200) {
5454
// do something repetitive 200 times
5555
var++;
5656
}
57+
// Here, do whatever comes after the while loop ends
5758
----
5859

5960
--
@@ -69,7 +70,7 @@ while (var < 200) {
6970
=== See also
7071

7172
[role="language"]
72-
73+
https://www.arduino.cc/reference/en/language/structure/control-structure/break/[Break^]
7374
[role="example"]
7475
* #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/WhileStatementConditional[While Loop^]
7576

0 commit comments

Comments
 (0)