aboutsummaryrefslogtreecommitdiffstats
path: root/source/arduino/break.rst
blob: d951c52d20bdcf7a4e37c740413b40f30e7a4058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.. _arduino-break:

break
=====

**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 < 255; x ++)
    {
        digitalWrite(PWMpin, x);
        sens = analogRead(sensorPin);  
        if (sens > threshold){      // bail out on sensor detect
           x = 0;
           break;
        }  
        delay(50);
    }