1

The LED_UPDATE() is called in my loop() function, I implemented it (tried anyways), to send sms as shown in the code such that only one sms is sent , because as the loop() keeps calling LED_UPDATE(), it's going to keep sending an sms every time (yep you guessed it, very bad for credit :o )

any tips on how I can get around this or what i'm doing wrong in my code would be much appreciated.

p.s. nearly left my mobile phone in the code lol

void LED_UPDATE(int state) 
{

int count; // initialized to zero, once program runs it automatically enter state ==1 
if (state == 1)
{

    digitalWrite(RED_PIN, LOW);
    digitalWrite(GREEN_PIN, HIGH);
    count=0; 
}
else if (state == 2)
{
  count+=1;
  Red_Blink();

  if(count == 1 )
  {
    sms.SendSMS("086XXXXXXX", "PANIC BUTTON PRESSED, Subject needs help!!!");
  }

}
  • Can you please add the code to sms.SendSMS(string phoneno,string msg) – Jahnavi Reddy Jan 28 '18 at 13:07
0

You are resetting count every time you enter the function.

static int count; // initialized to zero, once.

Adding the static statement should initialise the variable once and preserve its value between calls.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.