Back to Index

Definition: for (var = start; var <= end; var = var + step) { ... } — Allowed: identifier var and numeric expressions; Not allowed: missing iterator in condition/increment.

Counted loop. Ascending loops may use <= or <; descending loops may use >= or >. Step defaults to 1, step 0 is coerced to 1, and the condition direction must match the increment direction. Use break to exit early and continue to skip to the next iteration.

Example

// Blink outputs 1..4
for (i = 1; i <= 4; i = i + 1) {
  toggle(i);
  delay(200) { toggle(i); }
}