unsigned long previousTime1 = 0; // Variable to store the last time "2" was printed
unsigned long previousTime2 = 0; // Variable to store the last time "5" was printed
const long interval1 = 2000; // Interval for printing "2" in milliseconds (2 seconds)
const long interval2 = 5000; // Interval for printing "5" in milliseconds (5 seconds)
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
}
void loop() {
unsigned long currentTime = millis();
// Get the current tim
// Check if it's time to print "2"
if (currentTime - previousTime1 >= interval1) {
Serial.println("start - 2 ");
Serial.print(currentTime);
Serial.print(",");
Serial.print(previousTime1);
Serial.print(",");
Serial.print(interval1);
Serial.println("end - 2 ");
// Print "2" to the serial monitor
previousTime1 = currentTime; // Update the last time "2" was printed
}
// Check if it's time to print "5"
if (currentTime - previousTime2 >= interval2) {
Serial.println("start -5");
Serial.print(currentTime);
Serial.print(",");
Serial.print(previousTime2);
Serial.print(",");
Serial.print(interval2);
Serial.println("end -5");
// Print "5" to the serial monitor
previousTime2 = currentTime; // Update the last time "5" was printed
}
}