Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/MultiplePWM/Loop2.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// Task no.2

void loop2 () {
analogWrite(LED2, counter1);
counter1 += 50;
delay(500);
}
8 changes: 8 additions & 0 deletions examples/MultiplePWM/Loop3.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// Task no.3

void loop3 () {
analogWrite(LED3, counter2);
counter2++;
delay(7);
}
54 changes: 54 additions & 0 deletions examples/MultiplePWM/MultiplePWM.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Multiple PWM

Demonstrates the use of the Scheduler library

Hardware required :
* LEDs connected to PWM pins

created 28 Dic 2015
by Testato

*/


// Include Scheduler since we want to manage multiple tasks.
#include <Scheduler.h>

#define LED1 13
#define LED2 10
#define LED3 11
byte counter1;
byte counter2;


void setup() {

// Setup the led pins as OUTPUT
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);

// Add "loop2 and loop3" to scheduler
// "loop" is always started by default
Scheduler.startLoop(loop2);
Scheduler.startLoop(loop3);
}


// Task no.1 (standard Arduino loop() )
void loop() {
digitalWrite(LED1, HIGH);
delay(1000);
digitalWrite(LED1, LOW);
delay(1000);

// When multiple tasks are running, 'delay' passes control to
// other tasks while waiting and guarantees they get executed
// It is not necessary to call yield() when using delay()
}





51 changes: 51 additions & 0 deletions examples/MultipleSketch/MultipleSketch.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Multiple Sketch

Demonstrates the use of .start and .startLoop method of the Scheduler library

Hardware required :
* LEDs connected to pins

created 07 Gen 2016
by Testato

*/


// Include Scheduler since we want to manage multiple tasks.
#include <Scheduler.h>

#define LED1 13
#define LED2 10
#define LED3 11


// Sketch no.1

void setup() {
// Setup the led pin as OUTPUT
pinMode(LED1, OUTPUT);

// Add "setup2 and setup3" to scheduler
Scheduler.start(setup2);
Scheduler.start(setup3);
// Add "loop2 and loop3" to scheduler
Scheduler.startLoop(loop2);
Scheduler.startLoop(loop3);
}


void loop() {
digitalWrite(LED1, HIGH);
delay(1000);
digitalWrite(LED1, LOW);
delay(1000);

// When multiple tasks are running, 'delay' passes control to
// other tasks while waiting and guarantees they get executed
// It is not necessary to call yield() when using delay()
}




13 changes: 13 additions & 0 deletions examples/MultipleSketch/Sketch2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

// Sketch no.2

void setup2 () {
pinMode(LED2, OUTPUT);
}

void loop2 () {
digitalWrite(LED2, HIGH);
delay(500);
digitalWrite(LED2, LOW);
delay(500);
}
13 changes: 13 additions & 0 deletions examples/MultipleSketch/Sketch3
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

// Sketch no.3

void setup3 () {
pinMode(LED3, OUTPUT);
}

void loop3 () {
digitalWrite(LED3, HIGH);
delay(250);
digitalWrite(LED3, LOW);
delay(250);
}
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Scheduler KEYWORD1 Scheduler
# Methods and Functions (KEYWORD2)
#######################################

start KEYWORD2
startLoop KEYWORD2

#######################################
Expand Down