Arduino Mega with DFRobot 16x2 LCD keypad shield time lapse

hellow there i need help with my project im making a time lapse machine that controls the camera and 3 servos for movement the thing is im stuck in the middle i have this menu code which is not yet complete to have all menus but it is a sample :

// ========
#include <stdio.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 14, 9, 4, 5, 6, 7);
// ==========
// hardware settings
#define rightKey 0
#define upKey 1
#define downKey 2
#define leftKey 3
#define selectKey 4
#define NUM_KEYS 5
// =====
// Program parameters
#define minShots 1
#define maxShots 9999
int valueShots = 15;

#define minTime 1
#define maxTime 99
int valueTime = 10;

#define programMode1 0
#define programMode2 1
#define programMode3 2
int programMode = programMode1;

boolean inMainProgram = false;

int programmSequence = 0;
#define sequenceModeSelect 0
#define sequenceModeOption 1
#define sequenceModeProgram 2

// first menu line - description of menu level
char sequenceHeader[3][17] = {"Mode select ", "Option select ", "Program start "};

// second menu line - mode select
char sequenceModes[4][17] = {" Camera >", "< Yaw >", "< Slide >", "< Pitch >"};
// second menu line - options settings
char sequenceOptions[4][17] = {"Shots: ", "YDegree: ", "SDegree: ", "PDegree: "};

void setup()
{
// initial lcd display while initialize and pc detection
lcd.clear();
lcd.print(" AAMS TECH ");

programmSequence = sequenceModeSelect;
inMainProgram = false;

delay(3000);

updateScreen();
}

// main loop with new key detection
int keyEvent = -1;
int lastEvent = -1;
int countEvent = 0;

//Key message
char msgs[5][3] = {
"> ",
"^ ",
"v ",
"< ",
"* " };

void updateScreen()
{
lcd.clear();
lcd.print(sequenceHeader[programmSequence]);
lcd.setCursor(0,1);
switch(programmSequence)
{
case sequenceModeSelect:
menuModeSelect( keyEvent );
break;
case sequenceModeOption:
menuOptionSelect( keyEvent );
break;
case sequenceModeProgram:
break;
}
}

void loop()
{
int keyEvent = detectKey();
if (keyEvent >= 0)
{
switch (keyEvent)
{
case upKey:
if (!inMainProgram)
{
if (programmSequence > sequenceModeSelect)
programmSequence--;
updateScreen();
}
break;
case downKey:
if (!inMainProgram)
{
if (programmSequence < sequenceModeProgram)
programmSequence++;
updateScreen();
}
break;
case rightKey:
case leftKey:
if (!inMainProgram)
{
switch (programmSequence)
{
case sequenceModeSelect:
menuModeSelect( keyEvent );
break;
case sequenceModeOption:
menuOptionSelect( keyEvent );
break;
case sequenceModeProgram:
break;
}
}
break;
case selectKey:
lcd.setCursor(0, 1);
if (lastEvent != keyEvent)
{
lastEvent = keyEvent;
countEvent=0;
}
else
countEvent++;
lcd.print(msgs[keyEvent]);
lcd.print(countEvent);
break;
}
}
}

// ===========
// Menu tools

void menuModeSelect( int keyEvent )
{
switch (keyEvent)
{
case rightKey:
if (programMode < programMode3)
programMode++;
break;
case leftKey:
if (programMode > programMode1)
programMode--;
break;
}
lcd.setCursor(0,1);
lcd.print( sequenceModes[programMode] );
}

void menuOptionSelect( int keyEvent )
{
char cbuf[4] = " ";
lcd.setCursor(0,1);
lcd.print(sequenceOptions[programMode]);
switch (keyEvent)
{
case rightKey:
switch (programMode)
{
case programMode1:
if (valueShots < maxShots)
valueShots++;
break;
case programMode2:
if (valueTime < maxTime)
valueTime++;
break;
}
break;
case leftKey:
switch (programMode)
{
case programMode1:
if (valueShots > minShots)
valueShots--;
break;
case programMode2:
if (valueTime > minTime)
valueTime--;
break;
}
break;
}
switch(programMode)
{
case programMode1:
if (valueShots > minShots)
lcd.print("<");
else
lcd.print(" ");
sprintf(cbuf,"%3d",valueShots);
lcd.print(cbuf);
if (valueShots < maxShots)
lcd.print(">");
else
lcd.print(" ");
break;
case programMode2:
if (valueTime > minTime)
lcd.print("<");
else
lcd.print(" ");
sprintf(cbuf,"%2d",valueTime);
lcd.print(cbuf);
if (valueTime < maxTime)
lcd.print(">");
else
lcd.print(" ");
break;
}
}

// ===================================================================
// Lcd tools

void clearLine(int line)
{
lcd.setCursor(0,line);
lcd.print(" ");
lcd.setCursor(0,line);
}

// =======
// Define a custom char in lcd
int defineCharacter(int ascii, int data) {
int baseAddress = (ascii * 8) + 64;
// baseAddress = 64 | (ascii << 3);
lcd.command(baseAddress);
for (int i = 0; i < 8; i++)
lcd.write(data
);*

  • lcd.command(128);*
  • return ascii;*
    }
    // ===================================================================
    // Convert ADC value to key number
    int adc_key_val[NUM_KEYS] ={ 30, 150, 360, 535, 760 };
    int get_key(unsigned int input)
    {
  • int k;*
  • for (k = 0; k < NUM_KEYS; k++)*
  • {*
  • if (input < adc_key_val[k])*
  • return k;*
  • }*
  • if (k >= NUM_KEYS)*
  • k = -1; // No valid key pressed*
  • return k;*
    }
    // ========
    // new key detection routine, without delays!
    int lastKeyEvent = 0;
    int curKeyEvent = 0;
    int keyToReturn = 0;
    boolean keyToProcess = false;
    int adc_key_in = 0;
    int detectKey()
    {
  • keyToReturn = -1;*
  • adc_key_in = analogRead(0); // read the value from the sensor *
  • curKeyEvent = get_key(adc_key_in); // convert into key press*
  • if (curKeyEvent != lastKeyEvent)*
  • {*
  • if (!keyToProcess)*
  • {*
  • lastKeyEvent = curKeyEvent;*
  • keyToProcess = true;*
  • }*
  • else*
  • {*
  • keyToReturn = lastKeyEvent;*
  • lastKeyEvent = -1;*
  • keyToProcess = false;*
  • }*
  • }*
  • return keyToReturn;*
    }
    // =======
    i need this to simply control this code that have one servo in it not yet added the rest of them, i need it to take the values that i will enter in the keypad shield and use them to control the servos and camera shutter
    #include <Servo.h>

Servo servo1;// create servo object to control a servo
Servo servo2;

  • // a maximum of eight servo objects can be created*

int pos1 = 0; // variable to store the servo position
int pos2 = 0;
int n_phot=0;
void setup(){

  • servo1.attach(9); // attaches the servo on pin 9 to the servo object*
  • servo2.attach(8);*
  • pinMode(10,OUTPUT);*
  • pinMode(13,OUTPUT);*
  • Serial.begin(9600);*
    }
    void loop()
    {
  • for(pos1 = 0; pos1 < 180; pos1 += 10) // goes from 0 degrees to 180 degrees*
  • { // in steps of 1 degree*
  • servo1.write(pos1); // tell servo to go to position in variable 'pos'*
  • delay(5000);*
  • digitalWrite(10,HIGH);*
  • digitalWrite(13,HIGH);*
  • delay(500);*
  • digitalWrite(10,LOW);*
  • digitalWrite(13,LOW);*
  • n_phot+=1;*
  • Serial.print("took ");*
  • Serial.print(n_phot);*
  • Serial.println(" photos!");*
  • delay(15); // waits 15ms for the servo to reach the position*
  • }*
  • for(pos1 = 180; pos1>=1; pos1-=1) // goes from 180 degrees to 0 degrees*
  • { *
  • servo1.write(pos1); // tell servo to go to position in variable 'pos'*
  • delay(15); // waits 15ms for the servo to reach the position*
  • }*
    }

You need to learn how to use the forum first.
Delete this post and redo it using the CODE button [#] above so that people can scroll through the
code. Learn the other buttons as well, link the hyperlink {globe symbol] button and the "QUOTE"
button. This post is impossible to follow because you didn't use the CODE button. Redo it and we can
go from there...

READ THIS:
http://forum.arduino.cc/index.php/topic,148850.0.html