<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://code-reference.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://code-reference.com/feed.php">
        <title>Programming | Library | Reference - Code-Reference.com arduino:control_structures</title>
        <description></description>
        <link>https://code-reference.com/</link>
        <image rdf:resource="https://code-reference.com/ttps://code-reference.com/lib/tpl/dokuwiki/images/favicon.ico" />
       <dc:date>2026-04-25T14:55:47+02:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/break?rev=1708041848&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/continue?rev=1708041847&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/dowhile?rev=1708041848&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/else?rev=1708041848&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/for?rev=1708041847&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/goto?rev=1708041847&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/if?rev=1708041848&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/return?rev=1708041847&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/switchcase?rev=1708041848&amp;do=diff"/>
                <rdf:li rdf:resource="https://code-reference.com/arduino/control_structures/while?rev=1708041848&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://code-reference.com/ttps://code-reference.com/lib/tpl/dokuwiki/images/favicon.ico">
        <title>Programming | Library | Reference - Code-Reference.com</title>
        <link>https://code-reference.com/</link>
        <url>https://code-reference.com/ttps://code-reference.com/lib/tpl/dokuwiki/images/favicon.ico</url>
    </image>
    <item rdf:about="https://code-reference.com/arduino/control_structures/break?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>break</title>
        <link>https://code-reference.com/arduino/control_structures/break?rev=1708041848&amp;do=diff</link>
        <description>break is used to exit from a do, for, or while loop, bypassing the normal loop condition. It is also used to exit from a switch statement.

Example


for (x = 0; x &lt; 255; x ++)
{
    digitalWrite(PWMpin, x);
    sens = analogRead(sensorPin);  
    if (sens &gt; threshold){      // bail out on sensor detect
       x = 0;
       break;
    }  
    delay(50);
}</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/continue?rev=1708041847&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:07+02:00</dc:date>
        <title>continue</title>
        <link>https://code-reference.com/arduino/control_structures/continue?rev=1708041847&amp;do=diff</link>
        <description>The continue statement skips the rest of the current iteration of a loop (do, for, or while).  It continues by checking the conditional expression of the loop, and proceeding with any subsequent iterations.

Example



for (x = 0; x &lt; 255; x ++)
{
    if (x &gt; 40 &amp;&amp; x &lt; 120){      // create jump in values
        continue;
    }

    digitalWrite(PWMpin, x);
    delay(50);
}</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/dowhile?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>do - while</title>
        <link>https://code-reference.com/arduino/control_structures/dowhile?rev=1708041848&amp;do=diff</link>
        <description>The do loop works in the same manner as the while loop, with the exception that the condition is tested at the end of the loop, so the do loop will always run at least once.


do
{
    // statement block
} while (test condition);


Example


do
{
  delay(50);          // wait for sensors to stabilize
  x = readSensors();  // check the sensors

} while (x &lt; 100);</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/else?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>if / else</title>
        <link>https://code-reference.com/arduino/control_structures/else?rev=1708041848&amp;do=diff</link>
        <description>if/else allows greater control over the flow of code than the basic if statement, by allowing multiple tests to be grouped together. For example, an analog input could be tested and one action taken if the input was less than 500, and another action taken if the input was 500 or greater. The code would look like this:</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/for?rev=1708041847&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:07+02:00</dc:date>
        <title>for statements</title>
        <link>https://code-reference.com/arduino/control_structures/for?rev=1708041847&amp;do=diff</link>
        <description>Desciption

The for statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop. The for statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins.</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/goto?rev=1708041847&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:07+02:00</dc:date>
        <title>goto</title>
        <link>https://code-reference.com/arduino/control_structures/goto?rev=1708041847&amp;do=diff</link>
        <description>Transfers program flow to a labeled point in the program

Syntax

label: 

goto label;   sends program flow to the label

====Tip   ====
The use of goto is discouraged in C programming, and some authors of C programming books claim that the goto statement is never necessary, but used judiciously, it can simplify certain programs. The reason that many programmers frown upon the use of goto is  that with the unrestrained use of goto statements, it is easy to create a program with undefined program…</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/if?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>if  (conditional)  and   ==,  !=,   (comparison operators)</title>
        <link>https://code-reference.com/arduino/control_structures/if?rev=1708041848&amp;do=diff</link>
        <description>if, which is used in conjunction with a comparison operator, tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is:

if (someVariable &gt; 50)
{
  // do something here
}

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in parentheses is true, the statements inside the brackets are run. If not, the program skips over the code.</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/return?rev=1708041847&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:07+02:00</dc:date>
        <title>return</title>
        <link>https://code-reference.com/arduino/control_structures/return?rev=1708041847&amp;do=diff</link>
        <description>Terminate a function and return a value from a function to the calling function, if desired.

Syntax:

return;

return value;     both forms are valid

==== Parameters   ====

value: any variable or constant type

==== Examples:   ====

A function to compare a sensor input to a threshold
&lt;code arduino&gt; int checkSensor(){       
    if (analogRead(0) &gt; 400) {
        return 1;
    else{
        return 0;
    }
}&lt;/code&gt;

The return keyword is handy to test a section of code without having to “comm…</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/switchcase?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>switch / case statements</title>
        <link>https://code-reference.com/arduino/control_structures/switchcase?rev=1708041848&amp;do=diff</link>
        <description>Like if statements, switch...case controls the flow of programs by allowing programmers to specify different code that should be executed in various conditions.  In particular, a switch statement compares the value of a variable to the values specified in case statements.  When a case statement is found whose value matches that of the variable, the code in that case statement is run.</description>
    </item>
    <item rdf:about="https://code-reference.com/arduino/control_structures/while?rev=1708041848&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2024-02-16T01:04:08+02:00</dc:date>
        <title>while loops</title>
        <link>https://code-reference.com/arduino/control_structures/while?rev=1708041848&amp;do=diff</link>
        <description>Description

while loops 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.</description>
    </item>
</rdf:RDF>
