int startStopV1;
int timeBalanceV5;
int cyclesV2 = 50;
int duratiOnV3 = 5;
int idleV4 = 5;
bool flagTimeOnMillis = true;
int cycleBalanceV6;
//unsigned long timeCycle;
void setup() {
Serial.begin(115200);
Serial.println("CTAPT");
}
void loop()
{
Serial.print("startStopV1........ "); Serial.println(startStopV1);
Serial.print("cycleBalanceV6..... ");Serial.println(cycleBalanceV6);
Serial.print("timeBalanceV5...... ");Serial.println(timeBalanceV5);
Serial.print("flagTimeOnMillis... ");Serial.println(flagTimeOnMillis);
Serial.println();
if(startStopV1<1)
{
if(Serial.available()>0)
{
startStopV1 = Serial.parseInt();
}
}
if(cyclesV2 && duratiOnV3 && idleV4 > 0)
{
if(startStopV1 > 0)
{
int timeCycle;
if(flagTimeOnMillis)
{
timeCycle = millis()/1000;
//Serial.print("timeCycle.......... "); Serial.println(timeCycle);
flagTimeOnMillis = !flagTimeOnMillis;
}
else
{
//Serial.print("millis()........... "); Serial.println(millis()/1000);
//Serial.print("timeCycle.......... "); Serial.println(timeCycle);
//Serial.print("millis()-timeCycle. "); Serial.println(millis()/1000-timeCycle);
timeBalanceV5 = (cycleBalanceV6 * (duratiOnV3 + idleV4) - 1*(millis()/1000-timeCycle));
//Serial.print("timeBalanceV5...... ");Serial.println(timeBalanceV5);
//Serial.println();
if((millis()/1000-timeCycle) > duratiOnV3 + idleV4)
{
--cycleBalanceV6;
flagTimeOnMillis = !flagTimeOnMillis;
//Serial.print("flag............... "); Serial.println(flagTimeOnMillis);
}
}
}
else
{
cycleBalanceV6 = cyclesV2;
timeBalanceV5 = cyclesV2 * (duratiOnV3 + idleV4);
}
}
}