the reason why the if condition is outside the for loop, coz' i'm in a series of testing..
but i already tried to put the if condition inside the for loop, but it still the same..
if seconds is equal to 10, it sends message from GSM/GPRS shield but the loop stuck at 10 and never to continue again resulting to send message again and again...
I know the problem sir.. the problem is the if condition interrupt the loop when seconds is equal to 10 that's why the loop stuck at 10 and send message again and again and the loop never resume again..
the problem is I don't know how to resolve it.. is there another way to do this?
it's like multi-tasking correct me if i'm wrong. co'z it's some thing like continue to count while sending message every time the value of seconds is equal to 10 without interrupting the loop.
the problem is the if condition interrupt the loop when seconds is equal to 10 that's why the loop stuck at 10 and send message again and again and the loop never resume again..
I'm not sure I see your reasoning there.
There is no "interrupt", and the SMS send should not loop.
With a problem like this start without any SMS stuff. Just get your program to show on the serial monitor the stuff you want to send as an SMS. This will make debugging much easier.
When that works, write another short sketch that sends a fixed sms at fixed intervals.
co'z i think this is the same like i want to do to fix my problem in my project sir..
it is same as looping a number from 0-60 while sending message.
assuming that the loop a is the loop for counting from 0-60
and the loop b is sending a message. co'z when you send a message you need to wait at least 3sec before it done..
the problem is when im trying to combine it with gsm shield..
the GSM/GPRS shield need 3sec delay before sending is done..
that's why the loop stuck at 10 and send message again and again..
It sounds to me that you need to separate the sending from the counting. You should change your timing to use the technique in the Blink Without Delay example sketch. That will allow you to continue your count "in the background" while the GSM thing does its stuff. The extended demo of BWoD in the first post in this Thread may give you the idea.
Those for loops are not running at the same time. They are running one after the other.
the GSM/GPRS shield need 3sec delay before sending is done..
that's why the loop stuck at 10 and send message again and again..
It cannot simply be the 3 second delay during the message sending that is causing the for loop to stall at a value of 10. That would certainly mess up the timing if you use the delay() function but the for loop would then simply take longer to run and the timing would not be accurate.
You have not answered my earlier question about the value of seconds printed if you use a for loop with the send message function inside it. Does the for loop really stall at 10 ?
Using the BlinkWithoutDelay principle as suggested by others would get round the timing problem, at least within the limits of accuracy that the Arduino can provide without an external time reference.