Source: https://mokxi.com/errors/lvalue-required
Updated: 2026-11-16

Home / Errors
Arduino build error

# error: lvalue required as left operand of assignment

An assignment needs a place to store the value on its left: a variable. The left side was something else, such as a number, a constant or a calculation.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 487 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

A single = also sets a value, while == compares, so a mix-up between them can cause it.

Mokxi's compiler, clang, words it as expression is not assignable.

Causes

## The 2 usual causes with the fix

### 1The left side is a #define

A name made with #define is replaced by its text before compiling, so LED_PIN = 8 becomes 13 = 8. Use a variable to change it.

Broken

Fixed

Mokxi’s build tab says: The left side of = has to be a variable that can change.

Try this fix in Mokxi

### 2The left side is a calculation

count + 1 is a value, not a place. Assign to the variable itself.

Broken

Fixed

Mokxi’s build tab says: The left side of = has to be a variable that can change.

Try this fix in Mokxi

FAQ

## Questions and answers

### What is an lvalue?

Something that has a place in memory and can sit on the left of =, such as a variable. A number or a calculation is not one.

### Is this the same as using = in an if?

No. if (x = 5) compiles and always sets x. This error is for an assignment whose left side cannot be stored to.

### How do I change a #define value?

You cannot at run time. Use a variable for anything that changes, and keep #define or const for fixed settings.

Next

## More errors and the longer guide

- error: invalid types 'int[int]' for array subscript
- error: expected primary-expression before ')' token

The longer guide to this error All Arduino errors
