Is there alternative 51, 50 pin on arduino mega?

*I am new to arduino mega, *I am using SIM800L module and sd card module but both are using 50 and 51 pin.
I have tried all tx rx but nothing.
This is the code for gsm

#include <SoftwareSerial.h>
 
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 50
 
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 51
 
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
 
void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);
   
  //Being serial communication witj Arduino and SIM800
  serialSIM800.begin(9600);
  delay(1000);
   
  Serial.println("Setup Complete!");
}
 
void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(serialSIM800.available()){
    Serial.write(serialSIM800.read());
  }
  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){    
    serialSIM800.write(Serial.read());
  }
}

code for sd

/*SD card basic file example
  This example shows how to create and destroy an SD card file
  The circuit:
   SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on UNO, 51 on MEGA
 ** MISO - pin 12 on UNO, 50 on MEGA
 ** CLK - pin 13 on UNO, 52 on MEGA
 ** CS - pin 4 on UNO, 53 on MEGA*/
#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  if (SD.exists("example.txt")) {
    Serial.println("example.txt exists.");
  } else {
    Serial.println("example.txt doesn't exist.");
  }

  // open a new file and immediately close it:
  Serial.println("Creating example.txt...");
  myFile = SD.open("example.txt", FILE_WRITE);
  myFile.close();

  // Check to see if the file exists:
  if (SD.exists("example.txt")) {
    Serial.println("example.txt exists.");
  } else {
    Serial.println("example.txt doesn't exist.");
  }

  // delete the file:
  Serial.println("Removing example.txt...");
  SD.remove("example.txt");

  if (SD.exists("example.txt")) {
    Serial.println("example.txt exists.");
  } else {
    Serial.println("example.txt doesn't exist.");
  }
}

void loop() {
  // nothing happens after setup finishes.
}

Yes there is an alternative as the MEGA has more serial ports available if you look them up.

All you would need to do is define the pins in your first section of code for the GSM

Ballscrewbob: Yes there is an alternative as the MEGA has more serial ports available if you look them up.

All you would need to do is define the pins in your first section of code for the GSM

I have tried many other pins also defined them but nothing. Is there any specific?

Let's say you want to connect the SIM800 module to Serial1, pins 18 and 19. The SIM800 code would be changed to:

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);
   
  //Being serial communication witj Arduino and SIM800
  Serial1.begin(9600);
  delay(1000);
   
  Serial.println("Setup Complete!");
}

void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(Serial1.available()){
    Serial.write(Serial1.read());
  }
  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){   
    Serial1.write(Serial.read());
  }
}

Now there is no conflict with the SD module

pert: Let's say you want to connect the SIM800 module to Serial1, pins 18 and 19. The SIM800 code would be changed to:

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);
   
  //Being serial communication witj Arduino and SIM800
  Serial1.begin(9600);
  delay(1000);
   
  Serial.println("Setup Complete!");
}

void loop() {  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor  if(Serial1.available()){    Serial.write(Serial1.read());  }  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800  if(Serial.available()){      Serial1.write(Serial.read());  } }



Now there is no conflict with the SD module

So the solution is to use different serial communication. I thought there is not any conflict because sd card module does not have RX TX just MISO MOSI.

You can still use Software serial if you really want to but there's no reason to if you have multiple hardware serial channels on the Mega free. If you want to use software serial instead then you just need to be sure to use pins that support it, as listed in the reference for that library: https://www.arduino.cc/en/Reference/SoftwareSerial