Created
June 26, 2019 09:43
-
-
Save khthana/ecca1b2003279631c74113b420e2fed4 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, 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