Go Down

Topic: err: lvalue required as left operand of assignment (Read 7802 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy