Challenge

Project

#include <FreeRTOS.h>

void TaskBlink1( void *pvParameters );

void TaskBlink2( void *pvParameters );

void Taskprint( void *pvParameters );

void setup() {

// initialize serial communication at 9600 bits per second:

Serial.begin(9600);

xTaskCreate(TaskBlink1,"task1",128, NULL , 1 , NULL );

xTaskCreate( TaskBlink2, "task2", 128 , NULL, 1 , NULL );

xTaskCreate( Taskprint, "task3", 128, NULL, 1 , NULL );

vTaskStartScheduler();

}

void loop()
{
}

void TaskBlink1(void *pvParameters) {

pinMode(8, OUTPUT);

while(1)

{

Serial.println("Task1");

digitalWrite(8, HIGH);

vTaskDelay( 700 / portTICK_PERIOD_MS );

digitalWrite(8, LOW);

vTaskDelay( 700 / portTICK_PERIOD_MS );

}

}

void TaskBlink2(void *pvParameters)

{

pinMode(7, OUTPUT);

while(1)

{

Serial.println("Task2");

digitalWrite(7, HIGH);

vTaskDelay( 500 / portTICK_PERIOD_MS );

digitalWrite(7, LOW);

vTaskDelay( 500 / portTICK_PERIOD_MS );

}

}

void Taskprint(void *pvParameters) {

int counter = 0;

while(1)

{

counter++;

Serial.println(counter);

vTaskDelay(100 / portTICK_PERIOD_MS); }

}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.