Multiple Errors When Verifying Code

I’m kind of new to arduino and am having trouble with the code I’m trying to use with a serial controlled car I am building. I am using an arduino nano and I am trying to get the commands to work.

here is the code:

String command; // variable to store the command in

void setup(){
  // start serial and set up pins
  Serial.begin(9600);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop(){
  // systematically build up the command one letter at a time
  if (Serial.available() > 0){
    char c = Serial.read();
    
    if (c == '\n'){     // is this the end of the command
      handleCommand(command);
      command = ' ';
    }
    else{
      command += c;
    }
  }
}

void handleCommand(String com){
  // move the car
  if (com == ' forward'){
    digitalWrite(7, 1);
    digitalWrite(12, 1);
    delay(500);
    digitalWrite(7, 0);
    digitalWrite(12, 0);
  } else if (com == ' back'){
    digitalWrite(6, 1);
    digitalWrite(11, 1);
    delay(500);
    digitalWrite(6, 0);
    digitalWrite(11, 0);
  } else if (com == ' left'){
    digitalWrite(6, 1);
    digitalWrite(12, 1);
    delay(100);
    digitalWrite(6, 0);
    digitalWrite(12, 0);
  } else if (com == ' right'){
    digitalWrite(7, 1);
    digitalWrite(11, 1);
    delay(100);
    digitalWrite(7, 0);
    digitalWrite(11, 0);
  }
}

the errors I am receiving are:

arduino_car_bluetooth.ino.ino: In function 'void loop()':
arduino_car_bluetooth.ino.ino:17: error: ambiguous overload for 'operator=' in 'command = ' ''
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/WString.h:86: note: candidates are: String& String::operator=(const String&) <near match>
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/WString.h:87: note:                 String& String::operator=(const char*) <near match>
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/WString.h:88: note:                 String& String::operator=(const __FlashStringHelper*) <near match>
arduino_car_bluetooth.ino.ino: In function 'void handleCommand(String)':
arduino_car_bluetooth.ino.ino:26: error: invalid conversion from 'int' to 'const char*'
arduino_car_bluetooth.ino.ino:26: error:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'
arduino_car_bluetooth.ino.ino:32: error: invalid conversion from 'int' to 'const char*'
arduino_car_bluetooth.ino.ino:32: error:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'
arduino_car_bluetooth.ino.ino:38: error: invalid conversion from 'int' to 'const char*'
arduino_car_bluetooth.ino.ino:38: error:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'
arduino_car_bluetooth.ino.ino:44: error: invalid conversion from 'int' to 'const char*'
arduino_car_bluetooth.ino.ino:44: error:   initializing argument 1 of 'unsigned char String::operator==(const char*) const'

any help given will be much appreciated

For example, in this line:

  if (com == ' forward'){

you must do:

  if (com == " forward"){

Single quote (') is used for single characters, like you have in this line, for example:

      command = ' ';

but for strings is used double quote (").

thank you, i must have miss interpreted something along the line!

When you get a long list of errors just fix the first one. The others may magically disappear.

Because the Arduino has limited memory it is better to use strings (small s) rather than Strings (big S)

...R

any help given will be much appreciated

Then stop crossposting!

PaulS: Then stop crossposting!

Is not really a cross-post. The other post is an "upgraded question".