Snippets Collections
  if ((umiditate_sol > 43) && (umiditate_sol < 45)) 
#define EXE_INTERVAL_1 1000
#define EXE_INTERVAL_2 3000

unsigned long lastExecutedMillis_1 = 0; // vairable to save the last executed time for code block 1
unsigned long lastExecutedMillis_2 = 0; // vairable to save the last executed time for code block 2

void setup() {
  /*******************
   *  your setup code
   *******************/
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - lastExecutedMillis_1 >= EXE_INTERVAL_1) {
    lastExecutedMillis_1 = currentMillis; // save the last executed time

    /********************
     * your code block 1
     ********************/
  }

  if (currentMillis - lastExecutedMillis_2 >= EXE_INTERVAL_2) {
    lastExecutedMillis_2 = currentMillis; // save the last executed time

    /********************
     * your code block 1
     ********************/
  }
}
star

Sat Aug 21 2021 14:44:40 GMT+0000 (Coordinated Universal Time)

#millis #delay
star

Sun Aug 08 2021 16:03:12 GMT+0000 (Coordinated Universal Time) https://arduinogetstarted.com/faq/how-to-use-millis-instead-of-delay

#millis #delay

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension