Good evening everyone,
I am continuing my Arduino dishwasher project. Thing is, I noticed my code becomes unresponsive if I uncomment the "controlLED" function here:
void cycleRunning() {
display.setBacklight(100);
runCycle();
countDownFunction();
pauseCycleFunction();
detectErrors();
//controlLED();
if (millis() - lastButtonReadingTime > 100) {
buttonReading = readButtons();
lastButtonReadingTime = millis();
}
setButtons();
}
whereas If I leave it like that the code runs perfectly. Thing is, I need to control those LEDs for the control panel in order to give the user an idea of what is going on.
A coder friend of mine says you should never put too much code in switch cases (my bad really) but could that lead to instability? In particular, what happens is that the program runs well through currentCycleState 1,2 but when it goes to currentCycleState 3 I get that millis() - stageStartTime never becomes greater than zero. If I leve it commented everything runs fine
Also, if I edit the fillFunction like this:
bool fillFunction() {
switch (fillFunctionState) {
case 0: //activate fill solenoid
digitalWrite(fillSolenoid, HIGH);
interrupts(); // enable interrupts
fillFunctionState = 1;
break;
case 1: // static fill
if (flowMeterPulses >= 2 * FILL_PULSES / 3) {
digitalWrite(washingPump, HIGH);
}
if (flowMeterPulses >= FILL_PULSES) {
digitalWrite(fillSolenoid, LOW);
//fillSequenceStartTime = millis();
noInterrupts();//disable interrupts
//digitalWrite(washingPump, HIGH);
//timeFlowSwitchWasHigh = millis();
//fillFunctionState = 2;
}
Serial.println(F("OK"));
return true; // fill routine successful
break;
}
return false;
}
instead of this:
bool fillFunction() {
switch (fillFunctionState) {
case 0: //activate fill solenoid
digitalWrite(fillSolenoid, HIGH);
interrupts(); // enable interrupts
fillFunctionState = 1;
break;
case 1: // static fill
if (flowMeterPulses >= FILL_PULSES) {
digitalWrite(fillSolenoid, LOW);
noInterrupts();//disable interrupts
fillFunctionState = 2;
}
Serial.println(F("OK"));
return true; // fill routine successful
break;
case 2:
Serial.println("OK");
return true;
break;
}
return false;
}
the same problem manifests. Why is that?
Attached is the whole code, thanks in advance to anyone who can help me!
Arduino_Dishwasher_7SEG 3-8-22.zip (14.9 KB)