Skip to content

Instantly share code, notes, and snippets.

@khthana
Last active July 5, 2019 03:07
Show Gist options
  • Save khthana/0ae9649a06108e54f848696ac0c9d303 to your computer and use it in GitHub Desktop.
Save khthana/0ae9649a06108e54f848696ac0c9d303 to your computer and use it in GitHub Desktop.
#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