Okay, i need some help. Ill try to explain. Im trying to make some leds stay on for a certain time and then go off for a certain time. Over a 24 hour period. I would first like to see this in seconds, so that i know that it works.
This method will take in either 12.12, 18.6, 20.4 or 6.18.
Is then stored in lightcycleon and lightcycleoff. Ive tried using f.eks TimeAlarms. But i cant figure out how id cycle it properly, because the 2 alarms would interrupt eachother… hard to explain. Im not sure if im overthinking or underthinking this.
(Ive removed TimeAlarms and anything like that.) (Everything below is just how far ive got)
int setLedCycle(String cycle)
{
Serial.println("setLightCycle entered" );
Serial.println(cycle);
cycle.toCharArray(paramBuf, BUFFER_SIZE);
char *pch = strtok(paramBuf, ".");
lightcycleon = atoi(pch);
Serial.println(lightcycleon);
pch = strtok (NULL, ".");
lightcycleoff = atoi(pch);
Serial.println(lightcycleoff);
}
int setLedState(String lightValue) {
Serial.println("Test");
lightState = lightValue.toInt();
if(lightState==1) {
digitalWrite(D0, HIGH);
} else if(lightState==0){
digitalWrite(D0, LOW);
}
return 0;
}
void cycleOn() {
digitalWrite(D0, HIGH);
Serial.println("D0 set to high : LED ON!!");
}
void cycleOff(){
digitalWrite(D0, LOW);
Serial.println("D0 set to LOW : LED OFF!!");
}
Thanks alot for any answer