//-----------------------------
//M U L T I P R O C E S S I N G
//-----------------------------
  #include <Scheduler.h>//---------Task-Manager
  int led1 = 13;
  int led2 = 12;
  int led3 = 11;

  void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

//Starting void loop()//---------Task 1 is always started by default.
  Scheduler.startLoop(loop2);//--Task 2
  Scheduler.startLoop(loop3);//--Task 3
}

//Task 1: blink LED with 1 second delay.
  void loop()
{
  digitalWrite(led1, HIGH);
  delay(1000);
  digitalWrite(led1, LOW);
  delay(1000);
}

//Task 2: blink LED with 0.1 second delay.
  void loop2()
{
  digitalWrite(led2, HIGH);
  delay(100);
  digitalWrite(led2, LOW);
  delay(100);
}

//Task 3: accept commands from Serial port
//'0' turns off LED
//'1' turns on LED
  void loop3()
{
  if (Serial.available()) {
    char c = Serial.read();
    if (c=='0') {
      digitalWrite(led3, LOW);
      Serial.println("Led turned off!");
    }
    if (c=='1') {
      digitalWrite(led3, HIGH);
      Serial.println("Led turned on!");
    }
  }
  yield();
}