Last active
July 5, 2019 03:07
-
-
Save khthana/0ae9649a06108e54f848696ac0c9d303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino_FreeRTOS.h> | |
#define RED 6 | |
#define YELLOW 7 | |
#define BLUE 8 | |
const uint16_t *blueLed = (uint16_t *) BLUE; | |
const uint16_t *redLed = (uint16_t *) RED; | |
const uint16_t *yellowLed = (uint16_t) YELLOW; | |
const uint16_t taskParam[3][2] = { {BLUE, 50}, {RED, 100}, {YELLOW, 200} }; | |
void setup() { | |
xTaskCreate(LedControllerTask, "RED LED Task", 128, (void *)&taskParam[0], 1, NULL); | |
xTaskCreate(LedControllerTask, "BLUE LED Task", 128, (void *)&taskParam[1], 2, NULL); | |
xTaskCreate(LedControllerTask, "YELLOW LED Task", 128, (void *)&taskParam[2], 3, NULL); | |
} | |
void LedControllerTask(void *pvParameters) | |
{ | |
uint16_t *params = pvParameters; | |
int ledPin = params[0]; | |
int time = params[1]; | |
pinMode(ledPin, OUTPUT); | |
while (1) | |
{ | |
digitalWrite(ledPin, digitalRead(ledPin) ^ 1); | |
vTaskDelay(time); | |
} | |
} | |
void loop() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment