Welcome I'm currently working with a module() but I'm having trouble getting a message from a mobile to the module to turn the LED on and off.. All love to those who had the ability and offered me to solve a problem

قيد المعالجة: SIM800L_TEST_2021_osama.ino...
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3,2); // (Rx,Tx > Tx,Rx)

char incomingByte;
String inputString;
int relay = 13; // Output for Relay Control

void setup()
{
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW); // Initial state of the relay
Serial.begin(9600);
mySerial.begin(9600);

 while(!mySerial.available()){
    mySerial.println("AT");
    delay(1000); 
    Serial.println("Connecting...");
    }
    
  Serial.println("Connected!");  
  mySerial.println("AT+CMGF=1");  //Set SMS to Text Mode 
  delay(1000);  
  mySerial.println("AT+CNMI=1,2,0,0,0");  //Procedure to handle newly arrived messages(command name in text: new message indications to TE) 
  delay(1000);
  mySerial.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages
 }

void loop()
{
if(mySerial.available()){

  delay(100);

  // Serial Buffer
  while(mySerial.available()){
    incomingByte = mySerial.read();
    inputString += incomingByte; 
    }

    delay(10);      

    Serial.println(inputString);
    inputString.toUpperCase(); // Uppercase the Received Message

    //turn RELAY ON or OFF
    if (inputString.indexOf("ON") >=0){
      digitalWrite(relay, HIGH);
      Serial.println("OSAMAA");
      }
       delay(50);
     if (inputString.indexOf("OFF")>=0){
      digitalWrite(relay, LOW);
      }          

    delay(50);

    //Delete Messages & Save Memory
    if (inputString.indexOf("OK") == -1){
    mySerial.println("AT+CMGDA=\"DEL ALL\"");

    delay(1000);}

    inputString = "";

}
}

@osamaahmed2000, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

Please edit your post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

I suggest that you make use of Serial Monitor to debug your code; place Serial.print / Serial.println statements in strategic places so you can see what is happening.