-
Notifications
You must be signed in to change notification settings - Fork 29
/
multiloop.ino
44 lines (38 loc) · 932 Bytes
/
multiloop.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
/*Simple example of multi loop
* By Evandro Luis Copercini
* Based on pcbreflux video
* Public domain license 2017
*/
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
void loop1(void *pvParameters) {
while (1) {
Serial.println("loop1");
delay(1000);
}
}
void loop2(void *pvParameters) {
while (1) {
Serial.println("loop2");
delay(300);
}
}
void loop3(void *pvParameters) {
while (1) {
Serial.println("loop3");
delay(4000);
}
}
void setup() {
Serial.begin(115200);
xTaskCreatePinnedToCore(loop1, "loop1", 4096, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(loop2, "loop2", 4096, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(loop3, "loop3", 4096, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
}
void loop() {
Serial.println("loop0");
delay(5000);
}