Arduino Function: Scheduler.yield

Description

Passes control to other tasks when called. The function yield() should be used in functions that will take a long time to complete.

Syntax

yield();

Examples

#include 

int counter = 0;
int counter1 = 0;

void setup()
{
 Serial.begin(9600);

 Scheduler.startLoop(loop1);
}

void loop () {
analogWrite(9, counter);
counter++;
if (counter > 255){
 counter = 0;
}
delay(33);
}

void loop1 () {
if (Serial.available()) {
   char c = Serial.read();
   if (c=='0') {
     digitalWrite(2, LOW);
     Serial.println("Led turned off!");
   }
   if (c=='1') {
     digitalWrite(2, HIGH);
     Serial.println("Led turned on!");
   }
 }
yield();
}


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc