Re: SIM900 Shield SoftwareSerial Problem

hi all,
I am pritam I am doing a project with arduino uno. this project just count the number of interrupt(int 0) and send through gsm message when interrupt 1 occers(int 1).
I am putting a gsm program to control led according to sms text inside the never ending loop.

my interrupt program and gsm control program(inside never ending loop) are working individually but when I combined together nothing will work... what should i do

#include <LiquidCrystal.h>

char inchar; 
float b;
int timestosend=1;
int count= 0;
char mobile_number[]= "7200372879";

 int led1 = 5;
 int led2 = 13;
 int led3 = 11;
 int led4 = 12; 
int a=0;
int pbIn1 = 0; 
int pbIn2 = 1; 

LiquidCrystal lcd(8,9,10,11,12,13);

void setup() {
 
  lcd.begin(16, 2);

  pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 digitalWrite(led1, LOW);
 digitalWrite(led2, LOW);
 digitalWrite(led3, LOW);
 digitalWrite(led4, LOW);
 
  Serial.begin(9600);
 delay(3000); // give time for GSM module to register on network etc.
 Serial.println("AT+CMGF=1"); // set SMS mode to text
 delay(200);
 Serial.println("AT+CNMI=2,2,0,0,0"); // set module to send SMS data to serial out upon receipt 
 delay(200);
 
   attachInterrupt(pbIn1, counting, RISING);
  
  attachInterrupt(pbIn2, timing , RISING);
}

void loop() 
{

   if(Serial.available() >0)
 {
 inchar=Serial.read(); 
 if (inchar=='#')
   {
   delay(10);
   inchar=Serial.read(); 

 //first led
   if (inchar=='a')
     {
   delay(10);
   inchar=Serial.read();

 if (inchar=='0')
   {
   digitalWrite(led1, LOW);
   } 
 else if (inchar=='1')
   {
   digitalWrite(led1, HIGH);
   }
 delay(10);


 //Second led
 inchar=Serial.read(); 

 if (inchar=='b')
   {
   inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led2, LOW);
 } 

 else if (inchar=='1')
 {
 digitalWrite(led2, HIGH);
 }
 delay(10);

 // Third led
 inchar=Serial.read(); 
 if (inchar=='c')
 {
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led3, LOW);
 } 
 else if (inchar=='1')
 {
 digitalWrite(led3, HIGH);
 }
 delay(10);

 //Fourth led

 inchar=Serial.read(); 
 if (inchar=='d')
 {
 delay(10);
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led4, LOW);
 } 
 else if (inchar=='1')
 {
 digitalWrite(led4, HIGH);
 }
 delay(10);
 

 }
 }

 }
 }
   Serial.println("AT+CMGD=1,4"); // delete all SMS
   delay(2000);
 }

 }

}

void counting()
{
a++; 
Serial.println(a);
 lcd.setCursor(0,0);
lcd.print("C/NO=1000608062");
b=((a/3600)*1.5);
lcd.setCursor(1,1);
lcd.print("c=");
lcd.setCursor(3,1);
lcd.print(a);


lcd.setCursor(9,1);
lcd.print("A=");
lcd.setCursor(11,1);
lcd.print(b);

}

void timing()
{
while(count<timestosend)
{
delay(500);
Serial.print("AT+CMGS=\"");
Serial.print(mobile_number);
Serial.println("\"");
while(Serial.read()!='>');
{
  Serial.print("HEESA");
Serial.print("Hello Mr.PRITAM, this is to inform you that your last month reading is \n");
Serial.print(a);
Serial.print("You need to pay rupees\t");
Serial.print(b);
Serial.print("\n Within the date 5th of this month for continuing of your electric supplu");
delay(500);
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0x0A);
delay(5000);
}
count++;
}

}

kindly somebody help me

Serial prints and delays in interrupt context?

Please sort out the indentation - my eyes hurt.

Serial and delay are complete no-no's inside an ISR - they will hang the system since
they wait for other interrupts (which won't happen until the ISR returns).

What's also a no-no is checking to see if there's at least one character available to read, and then reading two or more.
Don't get me started on "delay()".