File tree Expand file tree Collapse file tree 7 files changed +148
-0
lines changed Expand file tree Collapse file tree 7 files changed +148
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ // Task no.2
3+
4+ void loop2 () {
5+ analogWrite (LED2, counter1);
6+ counter1 += 50 ;
7+ delay (500 );
8+ }
Original file line number Diff line number Diff line change 1+
2+ // Task no.3
3+
4+ void loop3 () {
5+ analogWrite (LED3, counter2);
6+ counter2++;
7+ delay (7 );
8+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Multiple PWM
3+
4+ Demonstrates the use of the Scheduler library
5+
6+ Hardware required :
7+ * LEDs connected to PWM pins
8+
9+ created 28 Dic 2015
10+ by Testato
11+
12+ */
13+
14+
15+ // Include Scheduler since we want to manage multiple tasks.
16+ #include < Scheduler.h>
17+
18+ #define LED1 13
19+ #define LED2 10
20+ #define LED3 11
21+ byte counter1;
22+ byte counter2;
23+
24+
25+ void setup () {
26+
27+ // Setup the led pins as OUTPUT
28+ pinMode (LED1, OUTPUT);
29+ pinMode (LED2, OUTPUT);
30+ pinMode (LED3, OUTPUT);
31+
32+ // Add "loop2 and loop3" to scheduler
33+ // "loop" is always started by default
34+ Scheduler.startLoop (loop2);
35+ Scheduler.startLoop (loop3);
36+ }
37+
38+
39+ // Task no.1 (standard Arduino loop() )
40+ void loop () {
41+ digitalWrite (LED1, HIGH);
42+ delay (1000 );
43+ digitalWrite (LED1, LOW);
44+ delay (1000 );
45+
46+ // When multiple tasks are running, 'delay' passes control to
47+ // other tasks while waiting and guarantees they get executed
48+ // It is not necessary to call yield() when using delay()
49+ }
50+
51+
52+
53+
54+
Original file line number Diff line number Diff line change 1+ /*
2+ Multiple Sketch
3+
4+ Demonstrates the use of .start and .startLoop method of the Scheduler library
5+
6+ Hardware required :
7+ * LEDs connected to pins
8+
9+ created 07 Gen 2016
10+ by Testato
11+
12+ */
13+
14+
15+ // Include Scheduler since we want to manage multiple tasks.
16+ #include < Scheduler.h>
17+
18+ #define LED1 13
19+ #define LED2 10
20+ #define LED3 11
21+
22+
23+ // Sketch no.1
24+
25+ void setup () {
26+ // Setup the led pin as OUTPUT
27+ pinMode (LED1, OUTPUT);
28+
29+ // Add "setup2 and setup3" to scheduler
30+ Scheduler.start (setup2);
31+ Scheduler.start (setup3);
32+ // Add "loop2 and loop3" to scheduler
33+ Scheduler.startLoop (loop2);
34+ Scheduler.startLoop (loop3);
35+ }
36+
37+
38+ void loop () {
39+ digitalWrite (LED1, HIGH);
40+ delay (1000 );
41+ digitalWrite (LED1, LOW);
42+ delay (1000 );
43+
44+ // When multiple tasks are running, 'delay' passes control to
45+ // other tasks while waiting and guarantees they get executed
46+ // It is not necessary to call yield() when using delay()
47+ }
48+
49+
50+
51+
Original file line number Diff line number Diff line change 1+
2+ // Sketch no.2
3+
4+ void setup2 () {
5+ pinMode(LED2, OUTPUT);
6+ }
7+
8+ void loop2 () {
9+ digitalWrite(LED2, HIGH);
10+ delay(500);
11+ digitalWrite(LED2, LOW);
12+ delay(500);
13+ }
Original file line number Diff line number Diff line change 1+
2+ // Sketch no.3
3+
4+ void setup3 () {
5+ pinMode(LED3, OUTPUT);
6+ }
7+
8+ void loop3 () {
9+ digitalWrite(LED3, HIGH);
10+ delay(250);
11+ digitalWrite(LED3, LOW);
12+ delay(250);
13+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ Scheduler KEYWORD1 Scheduler
1212# Methods and Functions (KEYWORD2)
1313#######################################
1414
15+ start KEYWORD2
1516startLoop KEYWORD2
1617
1718#######################################
You can’t perform that action at this time.
0 commit comments