SerialGSM
SerialGSM copied to clipboard
Sending feedback to the sender
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
in addition, whoever the sender is , he/she will get the reply or feedback. thanks