How to accept user input (array, variables,...) I am working on a project using my Arduino mega2560 that triggers a solenoid (maximum of three solenoids), my camera and my flash (maximum of two flashes). The core routine is there, and working. 

Now I want to refine this by adding a menu and 16x2 LCD with 6 buttons (up/down/left/right/select/reset). This is meant to be so the user can change the default values for:
- the amount of solenoids to be used (max 3),
- the amount of drops per solenoid (max 3),
- the time between drops and
- the time between active solenoids.
The layout of the menu is there, but not yet coded. 

My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array. Through the menu the default values will be presented to the user. He can accept (select button) or change the value within certain limits using the up/down buttons.

The question is, what is an easy (for a beginner like me) to program way to accept user input and store this in the array, overwriting the presented default value? I also would like to have the possibility for the user to back out of a menu option and leave the default setting of the specific submenu value.

I was thinking of creating a shadow array with blanks, to be filled in by the user and copy all the values to the array that will be used by the core routine. Another line of thinking leads me to just abandoning the array and making use of a bunch of variables. As you will probably see, I need some advice here.

Thanks very much for reading and your advice, happy to answer questions that may help clarify the issue.

Regards, Kiezel
Your hardware side for the user to use can be based on an ADC type keypad pictured below, this only uses one pin and is pretty reliable. Note that not all code is given or design as it would be useless for learning and I also put effort into the code this came from, logic helps with the rest of each part...


The code is pretty simple:

You would write a function like so~

char keypad(int in){

if(in &lt; 949){
    if(in &gt; 935){
        return 's'; //select
    }
}

//......

else return = 0;
}


Next would be the code for the menu, you could hold the default values in an array and then modify them in the code, with set positions for defaults, considering


  My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array.


Example from one of my projects

//Menu levels
#define level0 0
#define level1 1
#define level2 2
//master level of current point
#define mlevel 6        
#define msub_level 7
//\\\\\\\\\\\\\\\\\\\\  
#define sub_level1 0
#define sub_level2 1
#define sub_level3 2
#define sub_level4 3
#define sub_level5 4
// default level on boot
uint8_t current_level = mlevel;


Next would be to push the data to

int navigate(char key){
if(key == 'u'){
        if(current_level == mlevel){
        if(count == 3){ //roll-over

            count = 0;
            //update LCD....
        }
        else count++;
        //update LCD....
    }

    if(current_level == msub_level){

        if(count == 5){//roll-over

            count = 0;
            //update LCD....
        }
        else count++;
        //update LCD....
    }
}

//..... other ones here

    return count;
}


You would use the returned count to find the relative place in your array. e.g:

int default[n] ={x,y,z,...};


  get the key > put into navigate() > put into dafault[count];


You would also change the default after


It has been changed or,
The key has been debounced, i.e. use logic to determine if the key has changed state or,
The user has chosen 'accept'


Update of the LCD can be done at the points you want it done