You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide an example to call a function every 5 seconds. This code causes myFunction to be called thousands of time a second:
#include <WiFi.h>
#include <ezTime.h>
// Replace with your network credentials
const char* ssid = "your-SSID";
const char* password = "your-PASSWORD";
Timezone myTZ;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
// Wait for WiFi to connect
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
// Initialize ezTime and set the time zone
myTZ.setLocation("America/New_York"); // Replace with your time zone
// Synchronize time
waitForSync();
// Set the initial event to call myFunction after 5 seconds
myTZ.setEvent(myFunction, 5); // 5 seconds
Serial.println("Setup complete");
}
void loop() {
// Process scheduled events
events();
}
// Function to be called every 5 seconds
void myFunction() {
Serial.println("Function called every 5 seconds");
// Add your code here
// Schedule the next call to myFunction after another 5 seconds
myTZ.setEvent(myFunction, 5); // 5 seconds
}
The text was updated successfully, but these errors were encountered:
Please provide an example to call a function every 5 seconds. This code causes myFunction to be called thousands of time a second:
The text was updated successfully, but these errors were encountered: