Question about run multiple function

I use virtualpin to call some function, but I don’t know how to call function one bye one after a time like delay, example:
BLYNK_WRITE(V1)
{
function1();
“pause time”
function2();
“pause time”
function3();
{

sorry my bad English

you need simpletimer library

timer.setTimeout(1000L, function1);

calls function1 after 1 second

1 Like

Thanks for your help, anyway else, simple timer work with function, how about code, example
BLYNK_WRITE(V1) { some code abc "pause time" some code bcd "pause time" some code efg }

i don’t know enough about code to tell you how you should code it, i just know that simpletimer is probably what you should use :slight_smile:

learn about it here: http://playground.arduino.cc/Code/SimpleTimer

1 Like

Hi @NHN,
Have a look at this structure, I think it can do what you want.
This is not the complete code! Only the main items:

int sequence=0; // variable to be used for your functions

void setup() 
{
timer.setInterval(1000L, run_sequence); //Define the time between intervals
}

void run_sequence()
{
 if (sequence == 0){
  //some code A;
  }

 if (sequence == 1){
  //some code B;
  }
  
   if (sequence == 2){
  //some code C;
  }

if (sequence <= 2) {
     sequence++;  
    }
else {
    sequence = 0;  // Reset the sequence to start again
    }
}


void loop() {
  
Blynk.run();
timer.run(); 
}

With this code you would obtain a sequence like A, B, C ,A ,B ,C… every second.

Hope it helps!

4 Likes

thanks very much. I think your code is best way :smiley:

See, i only know WHAT to use, people like @psoro know HOW to use it :slight_smile:

1 Like

I just know where to ask. Sometime don’t know how to ask :smiley:

1 Like