Hi,
I am undertaking a few projects at the moment for a personal art installation in my backyard, and need help controlling multiple solenoid valves. Hardware wise everything is working, but need help with my code for the timing switching solenoids. I have a water feature project which has 5 different solenoid valves that I want to go off in a sequence, lasting for maybe 15-20 seconds. For the testing and assembly I've been using the delay() function, but the code is extremely long and I would like to add some lights (with a special timing aswell aswell) in the future so I would like to understand how to do this without delay(). I understand millis() may be the way to go, or potentially a timer library, but it seems quite complicated so far. The solenoids will mostly be off, with a small jet (roughly 40ms) when they shoot.
At least to start, activating solenoids 1 through 5 in order will be fine. I would like to set it up so I can play around with the timing and make something that looks cool with as little fiddling around as possible. I'm going to outline an example of what variables and parameters I want to include, I have not been able to make my visions come true yet, but I'm hoping it makes sense. If my way isn't good, I'm very open to any other way to tackle this. I want to be able to just adjust the timing every round that jets 1-5 activate, for 4-5 rounds. To activate a solenoid I basically just need to digitalWrite HIGH for the 40ms.
static const uint8_t VALVE_ARRAY[] = {8, 9, 10, 11, 12}; //array for the valve pins
onTime = 40 //milliseconds on for the jet to activate
timeBetweenJets1 = 1000 //milliseconds between the different solenoids during round 1 of the jets
timeBetweenJets2 = 800 //milliseconds between round 2 of the jets
timeBetweenJets3 = 600 //milliseconds between round 3 of the jets
timeBetweenJets4 = 400 //milliseconds between round 4 of the jets
Where do I go from here? I've tried many things but I get confused. I am using an arduino nano.
Thanks a lot!