Controlling program behaviour

Hello everybody ,

I have the following problem : I made a code (helped by a few people around) for my irrigation boom which is running pretty fine. At the moment everything is on presets selected from my touchscreen. So if you want to run the boom for its whole length and to irrigate with 5 l per hectare you select the button called "5l/ha". The boom start from its start point irrigate and stop and the other end waiting for a new command. Now I decide to make 4 different zones on the whole length for a different young plants.
What I need now is to create every time a custom user program , let say :

Irrigate zone 1 with 5l/ha
Not irrigate zone 2
Irrigate zone 3 with 10 l/ha
Irrigate zone 4 with 15 l/ha

The zones are dedicated by sensors so the boom knows where exactly every zone start and end. I also have the code for the dosing of the water for the different irrigation norms and the zones described in a different function.

The problem that I'm facing is how to say (take a look to the attached pic) to the arduino that it should run Irrigation - ZONE A - 5l/ha - ZoneB - 10l/ha - ZoneC -5l/ha - ZoneD - 15/l/ha.

At the afternoon the situation is different and I need Irrigation - ZONE A - 15l/ha - ZoneB - 0l/ha - ZoneC -10l/ha - ZoneD - 15/l/ha.

Should I create an array to store what I wish and then to read it and the to executed the functions stored inside or I have to write to the EEPROM or there is any other approach. Or may be there is a way to create a queue of function by the user and then to run them one after each other?

I hope that my explanation is good enough and thanks in advance to everybody that will give me some direction. Again , I'm not looking for a exact code , I'm looking for direction what I need to use as a means to make the program. If possible of course a few lines of code for better expression that will be useful also.

Use a spreadsheet to organize all the options you want and see how they can all fit into an array in your Arduino program.

Paul

Hello Paul , I can organise all functions but what is the idea to put them all in one array. I'm not sure that i understand the idea behind.

Thanks ,
Ivo.

One option: Use a two-dimensional array.

doserValue = table[zone][speed]

where speed is 0 or 1 for am/pm.

irrigate.PNG