Hello, i write a program to do something in specific time, when i send time through SMS to run if, i search in internet and didn't find something so i write this program, program working corect but i am not sure that is corect so i post it here and waiting for your opinion. From this program i didn't insert real time clock , i use HX711.h. If is easier way to do it?
// include the GSM library
#include <GSM.h>
// PIN Number for the SIM
#define PINNUMBER ""
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retreived from
String incometime = "";
int hourF = 0;
int minuteF = 0;
String aa = "";
String bb = "";
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM connection
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop() {
char c;
// If there are any SMSs available()
if (sms.available())
{
while (c = sms.read())
{
incometime += (char)c;
}
Serial.println(incometime);
char a = incometime.charAt(0); // store the first character of SMS received
char b = incometime.charAt(1); // store the second character of SMS received
char d = incometime.charAt(3); // store the forth character of SMS received
char e = incometime.charAt(4); // store the fifth character of SMS received
aa += a; // insert char a to string aa
aa += b; // insert char b to string aa
bb += d; // insert char d to string bb
bb += e; // insert char e to string bb
hourF = aa.toInt(); // string to integer
minuteF = bb.toInt(); // string to integer
}
if (hourF == 20 && minuteF == 50)
{
Serial.print("led ok");
hourF = 0;
minuteF = 0;
}
aa = "";
bb = "";
incometime = "";
sms.flush();
delay(1000);
}
3 days to write it, is long time ![]()