bule
February 16, 2014, 12:49pm
1
Here is my code:
else if (txtmsg.compareTo("status") == 0)
{
String statustxt = "";
pinstate = digitalRead(pin);
if (pinstate == 1){
sms.remoteNumber(remoteNumber, 10);
sms.beginSMS(remoteNumber);
sms.print(statustxt);
sms.endSMS();
}
}
I need to complete the code to do next (my pseudo code)
if txt message is status do next:
if pinstatus == 1
sting is: relay 'pin' is on
else
string is: relay 'pin' is off
sms.remoteNumber(remoteNumber, 10);
sms.beginSMS(remoteNumber);
sms.print(string);
sms.endSMS();
My brain is stuck, I mean I am stuck at how to create one string with two states.
system
February 16, 2014, 1:07pm
2
My brain is stuck, I mean I am stuck at how to create one string with two states.
Probably because that isn't what you want to do. You want to create a string (or String) with one of two different states.
char stg[32];
if(i == 27)
strcpy(stg, "The value really is 27");
else
strcpy(stg, "The value is not 27");
Random
indenting
even in
psuedo code
really isn't
a good
idea.
bule
February 16, 2014, 2:33pm
3
Ok. Thanks for the tip. But when I enter the line sms.print(stg);
What is going to print?
system
February 16, 2014, 3:32pm
4
Ok. Thanks for the tip. But when I enter the line ... What is going to print?
Whatever is in stg.
Do not post snippets here and expect much other than smart-assed answers.
bule
February 16, 2014, 6:33pm
5
Solved.
else if (txtmsg.compareTo("status") == 0)
{
char stg[32];
if (digitalRead(pin) == HIGH){
strcpy(stg, "Relej je ukljucen.");
}
else {
strcpy(stg, "Relej je iskljucen.");
}
Serial.println(stg);
sms.remoteNumber(remoteNumber, 10);
sms.beginSMS(remoteNumber);
sms.print(stg);
sms.endSMS();
}