SerialGSM icon indicating copy to clipboard operation
SerialGSM copied to clipboard

Sending feedback to the sender

Open jentuy opened this issue 8 years ago • 1 comments

Hi, I have this project which is to control the LED either on or off through sending SMS in GSM and i used this SerialGsm library. I successfully controlled the LED by turning it on or off through sms but the thing here is there is a digital input who will send feedback to the sender whether the LED is turn on or off, how can I program this? do you have any idea?

by the way here is the code:

include <SerialGSM.h>

include <SoftwareSerial.h>

SerialGSM cell(7, 8);

boolean sendonce = true; int ledpin = 9; int pin = 10; char c; String lastMessage;

void setup()

  {

     Serial.begin(9600);
     cell.begin(9600);
     cell.Verbose(true);
    // cell.Boot();
     cell.DeleteAllSMS();
     cell.FwdSMS2Serial();




          pinMode(pin, INPUT);
          pinMode(ledpin, OUTPUT);
          digitalWrite(ledpin, LOW);



   }

void loop()

{

         if(cell.available())

                    {


                           while( c = cell.read())


                                     {


                  switch(c)

                       {  



                        case 'H':


                         digitalWrite(ledpin, HIGH);
                         feedback_status();

                         cell.DeleteAllSMS();  


                        break;

                        case 'h':


                         digitalWrite(ledpin, LOW); 
                         feedback_status();

                         cell.DeleteAllSMS();  
                         break;



                 }
                         String character  = String(c);
                         String Message =(lastMessage + character);
                          lastMessage = Message;


           }         

     }

}

void feedback_status()

   {

      if(digitalRead(pin) == LOW)

                {     


                 cell.Rcpt(cell.Sender());

                 cell.Message("turn on");
                 cell.SendSMS();


                } 




     if(digitalRead(pin) == HIGH)

            {


                 cell.Rcpt(cell.Sender());

                 cell.Message("turn off");
                 cell.SendSMS();




        }


  }

Thank you

jentuy avatar Sep 19 '16 02:09 jentuy

in addition, whoever the sender is , he/she will get the reply or feedback. thanks

jentuy avatar Sep 19 '16 02:09 jentuy