I need help with a trouble with if()

My software is a motion sensor and when it is moved. A alarm sounds, and it send a SMS with coord. to a celphone , but when it detects motion only the alarm sounds and the SMS part is skipped and I don’t know why, sorry for my English is very bad

Software_Final_Melo.ino (2.96 KB)

It would be helpful if you would post your code.


Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

    digitalWrite(13, HIGH);
    Serial.println("Se mueve");
      while (serialgps.available())
        int c = serialgps.read();
        if (gps.encode(c))

My guess is that the serialgps buffer does not contain a complete GPS statement. I recommend you put the gathering of the GPS coordinates OUTSIDE the sending of the SMS. That way you can have the coordinates immediately available.

Note: You should probably check that the TinyGPS library has received a valid fix (if (gps.location.isValid())) before asking it for the coordinates. You don't want to replace good coordinates with bad coordinates.