Multiple loops in one program

void setup() {
setup1();
setup2();
}

void loop() {
loop1();
loop2();

}

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 7);
char a,inchar;
void setup1()

{ mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
mySerial.println(“AT+CMGF=1”);//text mode activate
delay(1000);
mySerial.println(“AT+CNMI=2,2,0,0,0\r”);
delay(1000);
mySerial.println(“AT+CMGD=1,4”);
pinMode(11, OUTPUT);
digitalWrite(11, LOW);
pinMode(12, OUTPUT);
digitalWrite(12, LOW);

}
void loop1()

{
if(mySerial.available() >0)
{
delay(10);
inchar=mySerial.read();
if (inchar==‘a’)
{
delay(10);
inchar=mySerial.read();
if (inchar==‘0’)
{
digitalWrite(12, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(12, HIGH);

}
}
}
}

void setup2()
{
mySerial.begin(9600);
Serial.begin(9600);
pinMode(2,INPUT_PULLUP);
delay(500);
}
void loop2()
{ a= digitalRead(2);
a= digitalRead(2);

if (a==1)

{
while(digitalRead(2)==1);
mySerial.println(“AT+CMGF=1”);//text mode activate
delay(500);
mySerial.println(“AT+CMGS=”+918058690708""); // use 1st mobile number
delay(500);
mySerial.print(“1.MAINS FAIL”);
mySerial.write(26);
delay(3000);
}

else if(a==0)
{

while(digitalRead(2)==0);

mySerial.println(“AT+CMGF=1”);//text mode activate
delay(500);
mySerial.println(“AT+CMGS=”+918058690708""); // use 1st mobile number
delay(500);
mySerial.print(“1.MAINS FAIL CLEAR”);
mySerial.write(26);
delay(3000);
}

}

i hve tray all possible things in this program but only on loop runnig at a time plz help me or provide soltion for both loop run simultaneouly

Please take a look at Read this before posting a programming question and follow the instructions on how to post code

Only one loop will run at a time because the loop1() and loop2() functions are called one after the other. To make things worse you have long delay()s in your code that stop anything else happening whilst they occur

You need to change how you manage the timing of events in your program so that it can run without blocking. Take a look at Using millis() for timing. A beginners guide, Several things at the same time and look at the BlinkWithoutDelay example in the IDE.

Both setups could be combined as there is only one line different. And it doesn't interfere with the first setup.

And you really only have one loop. The other 2 could be called sirloinSteak and mashedPotatoes (anyone else hungry?). They are just functions like any other function.