Browse Source

EP32 tasker script added

master
TeZ 3 years ago
parent
commit
553fc003c3
  1. 51
      ESP32/D1-ESP32-TASKER/D1-ESP32-TASKER.ino

51
ESP32/D1-ESP32-TASKER/D1-ESP32-TASKER.ino

@ -0,0 +1,51 @@
# include <Arduino.h>
#include <analogWrite.h>
int counter = 0;
long int deltask1 = 1 * 5 * 1000 / portTICK_PERIOD_MS; // 5 seconds
int ledPin = 2;
////////////////////////
void task1(void * parameters) {
for(;;){
myFunk(); // function to be called
vTaskDelay(deltask1); // reset delay time
}
}
/////////////////////////
void myFunk(){
Serial.print("task counter: ");
Serial.println(counter++);
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
}
////////////////////////
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
xTaskCreate(
task1, // function name
"Task1", // task name
1000, // stack size
NULL, // task parameters
1, // priority (low = more priority)
NULL // task handle
);
}
////////////////////////
void loop() {
// nada
}
Loading…
Cancel
Save