-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMultiplePWM.ino
54 lines (35 loc) · 932 Bytes
/
MultiplePWM.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
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()
}