Break

From Microduino Wiki
Revision as of 07:19, 4 August 2016 by Fengfeng (talk) (Created page with "*'''break''' Break is used to exit do, for, and while loop, and it can skip the common judge condition. And it can also exit the switch statement. *'''Example''' <pre style="...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • break

Break is used to exit do, for, and while loop, and it can skip the common judge condition. And it can also exit the switch statement.

  • Example

for (x = 0; x < 255; x ++)
{
    digitalWrite(PWMpin, x);
    sens = analogRead(sensorPin);  
    if (sens > threshold){      // beyond test range
       x = 0;
       break;
    }  
    delay(50);
}

[Return to Arduino Syntax Manual]