Why Do I Get "expected ';' before ..." ?

This error almost always means a missing semicolon on the line before the one shown.

What to check

  • Look at the line above the error.
  • Check for a missing semicolon after a statement.
  • Check for a missing closing brace or quote.

Example:

syntax_error.ino
cpp
int ledPin = 13
pinMode(ledPin, OUTPUT);

The fix is to add the semicolon after 13.

Bottom line

The error points to the next line, but the missing semicolon is usually right above it.

Related: What does this error message mean? · Why does my code compile but not work? · How do I use Serial Monitor correctly?