![]() ![]() These #defines just help keep track.Ĭonst int pumpRelayPin1 = 12 // Pin numbers for the pump relaysĬonst int floatSensorPin1 = 7 // Pin numbers for the float sensorsĬonst int pumpDuration = 500 // Number of millisecs that the pumps run #define RELAY_OFF 1 // and off when HIGH (1). #define RELAY_ON 0 // The pump relays are active-LOW on when LOW (0) -Edit these if you need to change the pin layout or pump duration How can I eliminate the code duplication? I believe I could use arrays and for loops but now I've entered another grey area for my knowledge level. I don't like that I've repeated so much code in the readFloatSensor functions, but this is where I am so far. I may not need to touch this code again for years and years (or a new house owner may need to look at it should I move out), so I tried to comment it as much as possible. Using info from every suggestion, I've so far come up with the following. (set timer to 300, and delay to 100ms) for better result.
0 Comments
Leave a Reply. |