Skip to content

Instantly share code, notes, and snippets.

@khthana
Created June 26, 2019 09:42
Show Gist options
  • Save khthana/30d6d3202ed9e2d177f018475d74b562 to your computer and use it in GitHub Desktop.
Save khthana/30d6d3202ed9e2d177f018475d74b562 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, 500}, {RED, 1000}, {YELLOW, 2000} };
void setup() {
xTaskCreate(LedControllerTask, "RED LED Task", 128, (void *)&taskParam[0], 1, NULL);
xTaskCreate(LedControllerTask, "BLUE LED Task", 128, (void *)&taskParam[1], 1, NULL);
xTaskCreate(LedControllerTask, "YELLOW LED Task", 128, (void *)&taskParam[2], 1, NULL);
}
void LedControllerTask(void *pvParameters)
{
uint16_t *params = pvParameters;
int ledPin = params[0];
int time = params[1];
pinMode(ledPin, OUTPUT);
while (1)
{
delay(time);
digitalWrite(ledPin, digitalRead(ledPin) ^ 1);
}
}
void loop() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment