this is some code i wrote but im having a strange issue with the pcf8574, it appears to randomly set some output states high. i thought maybe this was interference but now i think maybe something is wrong with my code. i have tried to find any bugs in this timer sequence but i failed.
the sequence starts out waiting for float sensors to become high state indicating empty tank. then the waterSolenoid and stirringPump are turned out until both float sensors are low indicating full tank. then pumps 1 - 5 run individually for their timers. then timerstate should become 0 and wait for the next cycle ,
i thought maybe this could be a code problem. at first my pcf8574 state was randomly changing high, the only way to the watersolenoid to turn off is if its called in the code and thats always followed by settings its state to false. however if shuts off without setting state to false. But incase i overlooked something i thought i could get a opinion of the problem
From what i can tell if i just set all the states low manually, they stay low, but when the timer is running even when there are no commands being sent to the pcf8574 it will go high
i don't understand why your so frustrated. why not have a reset function? if for whatever reason i need to quickly set all the pins of my pcf8574 high and reset the device then i need software reset. why solder wire to hw reset if i dont need to
Does the code in tank1TimerCode.h look okay? is there any reason in the code you see that may cause the tank1SolenoidPin to become high without setting tank1WaterSolenoidstate to false?
i Found 1 of my problems with the stirrer randomly.. shutting off,
if (tank1StirrerOn) {
if (!tank1StirState) {
tank1PCF.write(tank1Stirrer, 0);
tank1StirState = true;
tank1StirrerMillis = millis();
}
if (millis() - tank1StirrerMillis >= 360000) {
tank1StirrerOn = false;
tank1PCF.write(tank1Stirrer, 1);
}
}
i have removed that code but i still randomly have a problem with the solenoid pin.
I realize my code needs some improvements.
Sometimes when i come to check on it. the lcd says the waterpump and water solenoid are on but they are off. neither are suppose to shutoff untill the upper float sensor shows low input for 5 seconds to the arduino and that cant happen unless the tanks full. but ill come check on it and it says they are both on and the tank is not full and the solenoid pin state is not low as it should be.
it will sit like that until i improvise. if i manually move the float sensor with my hand it will continue the cycle like normal. but why is the solenoid shutting off before i designed it to? or did i?
btw the water pump is actually wire to the solenoid output so they both come on and off together.
I'm guessing nothing really stands out in the timercode that is causing my waterSolenoid to become in the high state before both of tank1 float sensors report low state for 5 seconds
Thing is, most well-designed programs don't need to do it at all. OP's code is triggering the reset based on a combination of digitalRead() statements. Likely because they painted themselves into a corner with blocking code and need to get out. Better programming would fix that.
I'm so glad all these response are so relevant to the questions I asked. All this helpful information is really solving my problem. I don't know what I would do without your kind attitude.