a) stell endlich dein erstes Post richtig, das kann man sonst nicht lesen.
b)
im Prinzip brauchst dir nur mal das Beispiel "Blink Without Delay" ansehen.
Anstatt dass du die LED Blinkst, startest deinen Ablauf.
verschiebe deinen jetzigen inhalt von loop() in eine neue Funktion void doIt().
mach eine Zeitsteuerung analog Blink Without Delay
Ruf im loop() die Zeitsteuerung auf.
Die Zeitsteuerung lässt du dein neues doIt() aufrufen solang du in den "Einzeiten" bist.
Nur so als Idee:
void trigger()
{
uint32_t currentMillis = millis(); // get current "time" - see example "Blink without delay"
static uint32_t previousMillis = 0; // time management
constexpr uint16_t onInterval = 30; // in seconds
constexpr uint16_t offInterval = 45; // in seconds
static bool isRunning = true; // flag if we are in on or off mode
if (isRunning)
{
// starte was du brauchst
doIt();
// prüfen auf Zeitablauf
if (currentMillis - previousMillis > onInterval * 1000UL)
{
previousMillis = currentMillis;
isRunning = false;
}
}
else
{
if (currentMillis - previousMillis > offInterval * 1000UL)
{
previousMillis = currentMillis;
isRunning = true;
}
}
}
void doIt()
{
// do all your current code from loop here
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
trigger();
}