-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parallel_blink.ino
67 lines (60 loc) · 1.22 KB
/
Parallel_blink.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <Arduino_FreeRTOS.h>
//red
int redPin_2 = 8;
//green
int redPin_3 = 4;
void Task2( void *pvParameters );
void Task3( void *pvParameters );
void setup() {
Serial.begin(9600);
Serial.println("********************Parallel Execution**************");
pinMode(redPin_2, OUTPUT);
pinMode(redPin_3, OUTPUT);
xTaskCreate(
Task2
, (const portCHAR *)"Task2"
, 128
, NULL
, 1
, NULL );
xTaskCreate(
Task3
, (const portCHAR *)"Task3"
, 128
, NULL
, 1
, NULL );
}
void loop() {
// put your main code here, to run repeatedly:
}
void Task2(void *pvParamaters) {
(void) pvParamaters;
//loop here
for (;;) {
Serial.println("RED LED Blinking");
setColor_led2();
delay(500);
}
vTaskDelete( NULL );
}
void Task3(void *pvParamaters) {
(void) pvParamaters;
//loop here
for (;;) {
Serial.println("GREEN LED Blinking");
setColor_led3();
delay(500);
}
vTaskDelete( NULL );
}
void setColor_led2() {
digitalWrite(redPin_2, HIGH);
delay(2000);
digitalWrite(redPin_2, LOW);
}
void setColor_led3() {
digitalWrite(redPin_3, HIGH);
delay(2000);
digitalWrite(redPin_3, LOW);
}