Go Down

Topic: err: lvalue required as left operand of assignment (Read 7007 times) previous topic - next topic

CoopMan

I get this error (error: lvalue required as left operand of assignment) with the following code:
Code: [Select]
void loop(){
 Serial.println("What do you want to do?");
 Serial.println("{1}Change pin state");
 [u][b]if (Serial.available() = 1){
[/b][/u]    serialData = Serial.read;
   switch(serialData){
     case 1: action1(); break;
     default: error(1); break;
   }
 }
}

I am writing a computer interface to control Arduino with just the builtin serial interface. Knowing me, it won't get far. :P

PaulS

Code: [Select]
if (Serial.available() = 1){


= is an assignment operator. == is a comparison operator.

This code is trying to assign the value 1 to Serial.read(), which it can't do.


Go Up