hey guys whats up, so i am parsing an sms message into an array, i am able to get the sms message, but i am having trouble comparing the sms to values, for eg,the sms is 9, i am getting problems comparing the value.
Below is my code
char character = 0;
char data[255];
int x=0;
int openingroof =53;
int closingroof =51;
int turningbeans = 52;
int buzzer = 49;
int manual_drawopenled =50;
int manual_drawcloseled = 48;
int smsled = 47;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
delay(60000);
pinMode(openingroof,OUTPUT);
pinMode(closingroof,OUTPUT);
pinMode(turningbeans,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(manual_drawopenled,OUTPUT);
pinMode(manual_drawcloseled,OUTPUT);
pinMode(smsled,OUTPUT);
Serial1.println("AT+CMGF=1");
}
void smsrecieve()
{
Serial1.println("AT+CMGR=1"); //Reads the first SMS
Serial1.flush();
for (x=0;x < 255;x++){
data[x]='\0';
}
x=0;
do{
while(Serial1.available()==0);
data[x]=Serial1.read();
x++;
if(data[x-1]==0x0D&&data[x-2]=='"'){
x=0;
}
}
while(!(data[x-1]=='K'&&data[x-2]=='O'));
data[x-3]='\0'; //finish the string before the OK
}
void loop()
{
smsrecieve();
if (data=="9")
{
digitalWrite(smsled,HIGH);
}
}
What happens is data is the array and the sms message is "9". Serial printin data will also show 9. Any ideas?