TaskHandle_t Task1;
TaskHandle_t Task2;
const int RedLED = 13; // LED pins
const int YelLED = 12; // LED pins
void setup()
{
Serial.begin(115200);
pinMode(RedLED, OUTPUT);
pinMode(YelLED, OUTPUT);
//create a task that will be executed in the Task1code() function,
//with priority 1 and executed on core 0
xTaskCreatePinnedToCore(
Task1code, /* Task function. */
"Task1", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task1, // Task handle to keep track of created task
0 /* pin task to core 0 */
);
delay(500);
//Task 2 on core 1
xTaskCreatePinnedToCore(
Task2code, /* Task function. */
"Task2", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task2, /* Task handle to keep track of
created task */
1); /* pin task to core 1 */
delay(500);
}
//Task1code: blinks an LED every 1s
void Task1code( void * pvParameters ){
while (1){
Serial.print("Task1 running on core ");
Serial.println(xPortGetCoreID());
digitalWrite(RedLED, HIGH);
delay(1000);
digitalWrite(RedLED, LOW);
delay(1000);
}
}
//Task2code: blinks an LED every 500 ms
void Task2code( void * pvParameters ){
while(1){
Serial.print("Task2 running on core ");
Serial.println(xPortGetCoreID());
digitalWrite(YelLED , HIGH);
delay(500);
digitalWrite(YelLED , LOW);
delay(500);
}
}
void loop() {
}