Skip to content

Commit c920dc7

Browse files
committed
Update MultiplePWM.ino
1 parent e2565f3 commit c920dc7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

examples/MultiplePWM/MultiplePWM.ino

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Demonstrates the use of the Scheduler library
55
66
Hardware required :
7-
* LEDs connected to pins 10 and 11 for the UNO board (on other board change the pwm pins)
7+
* LEDs connected to PWM pins
88
99
created 28 Dic 2015
1010
by Testato
@@ -15,17 +15,19 @@
1515
// Include Scheduler since we want to manage multiple tasks.
1616
#include <Scheduler.h>
1717

18+
#define LED1 13
19+
#define LED2 10
20+
#define LED3 11
1821
byte counter1;
1922
byte counter2;
20-
byte led1 = 10;
21-
byte led2 = 11;
2223

2324

2425
void setup() {
2526

2627
// Setup the two led pins as OUTPUT
27-
pinMode(led1, OUTPUT);
28-
pinMode(led2, OUTPUT);
28+
pinMode(LED1, OUTPUT);
29+
pinMode(LED2, OUTPUT);
30+
pinMode(LED3, OUTPUT);
2931

3032
// Add "loop2 and loop3" to scheduler
3133
// "loop" is always started by default
@@ -36,7 +38,14 @@ void setup() {
3638

3739
// Task no.1 (standard Arduino loop() )
3840
void loop() {
39-
yield();
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()
4049
}
4150

4251

0 commit comments

Comments
 (0)