you can create a new sketch and use the following code:
#include <Arduino.h>
unsigned long startTime;
byte daysPassed = 0;
unsigned long previousMillis = 0;
const long interval = 86400000; // 24 hours in milliseconds
void setup() {
Serial.begin(9600);
startTime = millis();
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
daysPassed++;
Serial.print("Days passed: ");
Serial.println(daysPassed);
}
// Your code with conditionals based on 'daysPassed' goes here
if (daysPassed == 3) {
// Do something when 3 days have passed
} else if (daysPassed == 7) {
// Do something when 7 days have passed
}
}
This code sets up a basic Arduino sketch that counts the days since it started running. It uses the millis() function to track the time elapsed and increments the daysPassed variable every 24 hours. You can add your conditionals based on the daysPassed variable in the loop() function, as shown in the example.
Keep in mind that the millis() function will roll over (go back to zero) after approximately 50 days, so you may want to consider using a Real-Time Clock (RTC) module if you need to track time for longer periods or if you need more accurate timekeeping.