Commit 2e543e87 by Risto Heinsar

Added scheduler example using millis()

parent deab1007
const unsigned task1Period = 500; /* iga 500 ms järel */
const unsigned task2Period = 250; /* iga 100 ms järel */
void setup()
{
Serial.begin(9600);
}
void loop()
{
static uint32_t task1LastRun = 0;
static uint32_t task2LastRun = 0;
uint32_t currentTime = millis();
/* Ülesannet lahendatakse iga 500 ms järel */
if (currentTime - task1LastRun >= task1Period)
{
task1LastRun = currentTime;
Serial.print(millis() / (float)1000);
Serial.println(" Olen Boe-Bot");
}
/* Ülesannet lahendatakse iga 250 ms järel */
if (currentTime - task2LastRun >= task2Period)
{
task2LastRun = currentTime;
Serial.print(millis() / (float)1000);
Serial.println(" Beep-Boop");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment