--- title: break categories: [ "Structure" ] subCategories: [ "Control Structure" ] --- = break // OVERVIEW SECTION STARTS [#overview] -- [float] === Description [%hardbreaks] `break` is used to exit from a `link:../for[for]`, `link:../while[while]` or `link:../dowhile[do...while]` loop, bypassing the normal loop condition. It is also used to exit from a `link:../switchcase[switch case]` statement. [%hardbreaks] -- // OVERVIEW SECTION ENDS // HOW TO USE SECTION STARTS [#howtouse] -- [float] === Example Code In the following code, the control exits the link:../for[`for`] loop when the sensor value exceeds the threshold. [source,arduino] ---- int threshold = 40; for (int x = 0; x < 255; x++) { analogWrite(PWMpin, x); sens = analogRead(sensorPin); if (sens > threshold) { // bail out on sensor detect x = 0; break; } delay(50); } ---- -- // HOW TO USE SECTION ENDS // SEE ALSO SECTION BEGINS [#see_also] -- [float] === See also [role="language"] -- // SEE ALSO SECTION ENDS