Will This Work?


void setup()
{
  timer1.initilize(1);
  timer1.attachinterrupt(loop_1);

  timer2.initialize(1);
  timer2.attachinterrupt(loop_2);
}

void loop_1()
{
  //maybe uart communication here
}

void loop_2()
{
  //maybe esp8266 at-command programming here
}

void loop()
{
  //maybe sensor reading here
}


will work? if no, why?

i intend create more independent loops arduino. in case, arduino fast enough, using 1 'brain' control everything, experiences miss-out.

your idea not work if mean have code sections loop whilst doing things. 

you cannot 2 things @ once can run several things 1 after other appear running @ same time.  trick break processes small sections , them quickly.  instance, instead of while loop waiting input sensor or user, check whether input available , if not move on , else , come later , check input.

see  using millis() timing.  beginners guide,   several things @ same time , @ blinkwithoutdelay example in ide.


Arduino Forum > Using Arduino > Programming Questions > Will This Work?


arduino

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???