Pages: [1]   Go Down
Author Topic: err: lvalue required as left operand of assignment  (Read 6337 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I get this error (error: lvalue required as left operand of assignment) with the following code:
Code:
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. smiley-razz
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 644
Posts: 50452
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you. I forgot.
Logged

Pages: [1]   Go Up
Jump to: