Reference Language | Libraries | Comparison | Changes
Scheduler
yield()
Description
Passes control to other tasks when called. Ideally yield()
should be used in functions that will take awhile to complete.
Syntax
yield();
Parameters
none
Returns
nothing
Example
#include <Scheduler.h>
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();
}
Reference Home
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a
Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.