From 7c20a139aa10e3f50557b71f1c17c6ba5b787ab3 Mon Sep 17 00:00:00 2001 From: Graybeard2ca <57457114+Graybeard2ca@users.noreply.github.com> Date: Fri, 5 Mar 2021 19:19:38 -0700 Subject: [PATCH] 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 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? --- Language/Structure/Control Structure/while.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Language/Structure/Control Structure/while.adoc b/Language/Structure/Control Structure/while.adoc index 09b25192..8f349365 100644 --- a/Language/Structure/Control Structure/while.adoc +++ b/Language/Structure/Control Structure/while.adoc @@ -54,6 +54,7 @@ while (var < 200) { // do something repetitive 200 times var++; } +// Here, do whatever comes after the while loop ends ---- -- @@ -69,7 +70,7 @@ while (var < 200) { === See also [role="language"] - + https://www.arduino.cc/reference/en/language/structure/control-structure/break/[Break^] [role="example"] * #EXAMPLE# https://www.arduino.cc/en/Tutorial/BuiltInExamples/WhileStatementConditional[While Loop^]