-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels