hi all, can someone help me to code for try function on arduino. by using relays, ultrasonic sensors and flow sensors. My goal in making this is to build an automatic pump, where sometimes when the pump is on the water tank is not full, but the water source suddenly runs out and I have to manually turn off the pump and turn it back on a few minutes later to check the water source is there.
There are several conditions where the relay must be on and must be off. for example if the tank is empty then the relay / pump is on, but when the relay is on for 10 seconds and if there is no water flowing on the flow sensor then the relay turns off for 20 seconds and turns on again for 10 seconds while checking the water flow, repeats for 3 times, if in the process there is water flow then the relay/pump will continue to turn on until the tank is full, but if in the process there is still no water flow then the relay/pump must be off for 1 minute, and if after 1 minute the relay is off, the relay returns position trying early.
theory :
tank is empty (YES)
relay (ON) for 10 second while check water flow
(YES) water flowing, relay ON until tank is full, but if
(NO) water flowing, relay off for 20 second.
repeat 3 times.
if still (NO) water flowing, then relay OFF for 1 minute, after that start from beggining.
Yes but no helper will do the entire coding.
Start by dividing the project into smaller parts.
Reading buttons or switches is one part.
Handling a relay module is another.
Draw up a map for the flow of the code. The name is: Flow charts. That map should tell the different timings of events, when they will we activated and how.
Hello Romiez_Fach
Post your current sketch, well formated, with comments and in so called code tags "</>" and a schematic, not a Fritzy diagram, to see how we can help.
Have a nice day and enjoy coding in C++.
Hello Romiez_Fach
I have made a small review of the given sketch snipset.
My recoemmendation take some time, study the IPO model and take a piece of paper plus a pencil and design a program structure. Identify modules could to be coded and tested separetly. Merge after sucessfull testing all modules together to the needed project.
It is highly recommented to take a view into some powerful C++ instructions like STRUCT, ENUM, ARRAY, CASE/SWITCH,UDT, RANGE-BASED-FOR-LOOP, etc, too.