I need your helping hand ...

how can i change all the delay into millis?

Serial.print("\r");
delay(1000);
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial.print("AT+CMGS="09331678931"\r"); //Number to which you want to send the sms
delay(1000);
Serial.print("Hello World..!!"); //The text of the message to be sent
delay(1000);
Serial.write(0x1A);
delay(1000);

iam stock here so long i dont know how to change it into millis i know how to use millis but in this case i dont know how to apply here in this scenario.. so please lend me your helping hand any kind of help is much appreciated... sorry for my bad english... tnx in advance guys.

I don't understand your question...

The delay time is in milliseconds, so delay(1000) is a one second delay. delay(500) is half a second. delay(1) is a one millisecond delay (1/1000th of a second).

i know how to use millis

Are you sure you understand millis()? There is a function called [u]millis()[/u] that gives you the time (or "count") in milliseconds since your program started.

By reading that time, you can create timers or "delays", such as the [u]Blink Without Delay Example[/u]. You can use millis() to time an event or to wait a certain amount of time before doing something (like in the Blink Without Delay Example) while your loop continues to run and do other things.

You with millis() can have multiple timers or multiple "delays" all with with different interval variables, all running "at the same time". I've got a program that does one thing 10 times per second while another timer runs a loop for about 30 seconds. (Well, the timer isn't "running" the loop, but the loop exits when the time is up.)

If the code above does what you want, I don't see the need to change it. Using millis enables you to do other things between the Serial.prints, rather than do nothing. So do you want to do something? If not, what you've got is legitimate.

Put the messages in a table.
Create a timer 'tick' of 1s with millis().
Walk through the table at every 'tick'.
That would require a certain amount of code, but it will be easy and straightforward code, and it will be easy to expand.

Is something like that what you want to achieve ?

tnx for your response guys..

i want to change the all the delays into millis coz if i use delay instead of millis all the process in my project will stop until the delay is done.. all i want is to send all that line one by one using millis instead of using delay while other process is working..

Did you understand my Reply #3 ?
Did you check the "blink without delay" as DVDdoug wrote ?
And I also want to know what the other processes are, as Nick_Pyner wrote.

yes sir i understand the blink without delay... it include stat change correct me if im wrong.

this is for my logger. i have tipping bucket, sd card shield and gsm shield..

it records into my sd card shield everytime the tipping bucket tipped and sends a message every one hour..

the problem is everytime the gsm send a message it affect the recording of tipping bucket in sd card because gsm shield need 5 secs to send a message. thats the reason why i want to change the delay into millis. i hope you understand sir tnx

I also don't understand why people don't understand that cross-posting is a really bad idea, because it make me CROSS.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.

Duplicate topic deleted.

The demo several things at a time is an extended example of BWoD.

...R

I like to create a timer 'tick' of 1 second. That is a section in the sketch that runs once a second. It is the same what Delta_G writes about, the only difference is that I give it the name: "tick" :stuck_out_tongue:

// Tested with Arduino 1.5.8
// For PROGMEM use, see http://www.gammon.com.au/progmem
//

unsigned long prevMillis;

const char t0[] PROGMEM = "\r";
const char t1[] PROGMEM = "AT+CMGF=1\r";
const char t2[] PROGMEM = "AT+CMGS=\"09331678931\"\r";
const char t3[] PROGMEM = "Hello World..!!";
const char t4[] PROGMEM = "\x1A";

const char * const table[] PROGMEM = { t0, t1, t2, t3, t4, NULL, };

int table_index = -1;    // -1 is don't do anything, 0 is start

void setup()  
{
  Serial.begin(9600);
  Serial.println(F("Sketch is running, type a to start."));
  
  // do other initialization here.
  
  
  // at the very end of setup(), set the prevMillis.
  prevMillis = millis();
}

void loop()  
{
  // do the normal other tasks here
  
  
  // Test if the strings have to be send.
  // It is started by setting table_index to 0
  // For now, I use the command 'a' to start.
  if( Serial.available())
    if( Serial.read() == 'a')
      table_index = 0;          // start it !
  
  
  // create a timer 'tick' of 1 second
  unsigned long currentMillis = millis();
  if( currentMillis - prevMillis > 1000)
  {
    // Set prevMillis for the next tick.
    // Set to "minimal" 1 second.
    // A delay in the sketch, will delay the 1 second.
    prevMillis = currentMillis;

    // This part is the 1 second 'tick'.
    
    if( table_index >= 0)
    {
      const char * const pText = (const char *) pgm_read_word(&table[table_index]);
      if( pText == NULL)          // end of list ?
      {
        // end of list
        table_index = -1;         // stop it.
      }
      else
      {
        char buffer[40];    // large enough to hold the longest string.
        
        strcpy_P( buffer, pText);
        Serial.println( buffer);
        table_index++;            // set to next string
      }
    }
  }
}