invalid conversion from 'const char*' to 'char'

// include the GSM library
#include <GSM.h>


// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

int led = 13; //pin 13

char inchar;

void setup() 
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 pinMode(13, OUTPUT);
 digitalWrite(13, LOW); 

  Serial.println("SMS Messages Receiver");
  
}

void loop() 
{
  
  
  
  // If there are any SMSs available()  
  if (sms.available())
  {
   inchar=Serial.read();
    { if(inchar = "ledon"){
      digitalWrite(13, HIGH);}
    
    if(inchar = "ledoff"){
      digitalWrite(13, LOW);}
      
    
    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }

  delay(1000);

}
}

I'm trying to control an LED using Arduino by using SMS.
And I get this error: invalid conversion from 'const char*' to 'char'.

So I need help to correct my coding please. v.v

You define inchar as a char, which is a single-byte data type. You then use the if statement:

    { if(inchar = "ledon"){

There's two problems here. First, you are using the assignment operator (=) where the if expression require a relational test, probably for equality in your code, which is a double equal sign in C/C++ (==) . Second, how can you assign the string "ledon", which actually requires 6 bytes of storage, into the 1-byte variable inchar. Even if you were using the correct operator, you still have problems comparing the two data types. I don't know what sms.available() returns, but you're assuming it's a single byte. You may need to go back and read the library specs to find out what is expected.

Thanks! With your help, me managed to compile it. But then, we can't make the project works as we expected.

Sorry for the late reply.

we can't make the project works as we expected.

Then you need to post the current code and describe the problem if you still want help.


Rob