paaav
July 30, 2022, 10:30pm
1
Hi everyone,
I am dealing with problem during implementation RTOS blinking LED on esp32. I want to send message during the execution of the task and I receive only "<0>". Here is my code:
#define RED 43
#define GREEN 44
#define YELLOW 1
void setup() {
Serial.begin(115200);
delay(100);
xTaskCreate(redLedControllerTask, "RED LED Task", 1024, NULL, 1, NULL);
xTaskCreate(greenLedControllerTask, "GREEN LED Task", 1024, NULL, 1, NULL);
xTaskCreate(yellowLedControllerTask, "YELLOW LED Task", 1024, NULL, 1, NULL);
}
void redLedControllerTask(void *pvParameters)
{
pinMode(RED, OUTPUT);
while(1)
{
digitalWrite(RED, digitalRead(RED)^1);
Serial.print("TASK RED");
vTaskDelay(500);
}
}
void greenLedControllerTask(void *pvParameters)
{
pinMode(GREEN, OUTPUT);
while(1)
{
digitalWrite(GREEN, digitalRead(GREEN)^1);
Serial.print("TASK GREEN");
vTaskDelay(500);
}
}
void yellowLedControllerTask(void *pvParameters)
{
pinMode(YELLOW, OUTPUT);
while(1)
{
digitalWrite(YELLOW, digitalRead(YELLOW)^1);
Serial.print("TASK YELLOW");
vTaskDelay(500);
}
}
void loop() {}
How I can send message from the task?
paaav
July 30, 2022, 11:31pm
3
Unfortunately that didn't help.
What does that mean to send a message from the task?
paaav
July 31, 2022, 9:32am
5
To send message to serial port from the task as it is shown in code.
Those task as they are written do not produce any serial monitor output?
What does this line of code mean:
`digitalWrite(RED, digitalRead(RED)^1);`
Why not use digitialWrite(RED, HIGH );
or (digitialWrite(Red,LOW);
? How do you read a digital pin that has been set as an output?
When you run this does it produce serial monitor output?
#define RED 43
#define GREEN 44
#define YELLOW 1
void setup() {
Serial.begin(115200);
delay(100);
xTaskCreate(redLedControllerTask, "RED LED Task", 1024, NULL, 1, NULL);
xTaskCreate(greenLedControllerTask, "GREEN LED Task", 1024, NULL, 1, NULL);
xTaskCreate(yellowLedControllerTask, "YELLOW LED Task", 1024, NULL, 1, NULL);
}
void redLedControllerTask(void *pvParameters)
{
//pinMode(RED, OUTPUT);
while(1)
{
//digitalWrite(RED, digitalRead(RED)^1);
Serial.print("TASK RED");
vTaskDelay(500);
}
}
void greenLedControllerTask(void *pvParameters)
{
//pinMode(GREEN, OUTPUT);
while(1)
{
//digitalWrite(GREEN, digitalRead(GREEN)^1);
Serial.print("TASK GREEN");
vTaskDelay(500);
}
}
void yellowLedControllerTask(void *pvParameters)
{
//pinMode(YELLOW, OUTPUT);
while(1)
{
//digitalWrite(YELLOW, digitalRead(YELLOW)^1);
Serial.print("TASK YELLOW");
vTaskDelay(500);
}
}
void loop() {}
Using pin1 of an ESP32 is not a good idea. And which ESP32 are you using that has pins 43 and 44?
paaav
July 31, 2022, 8:54pm
7
digitalWrite(RED, digitalRead(RED)^1);
That line will change output to LOW when it is HIGH and to HIGH when it is LOW.
When I turn off blinking LEDs then task send message via serial port.
I noticed when two LEDs are blinking then everything is allright but when I turn on third LED then serial port will recive only "<0>".
paaav
July 31, 2022, 8:56pm
8
But it is only when I use commands digitialWrite(, HIGH ); and digitialWrite(,LOW)
system
Closed
January 27, 2023, 8:57pm
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.