project with servos, lcd and keypad 4x4

Hi guys
i have a problem with my code dont know what else to do. look i need to do 2 menus, one who asks the servo control (1 to 3) and the other to enter the angle from 0 to 180°. but when i select the servo, but when the servo selected on the display moves to the next menu but the servo move to the selected number 1, 2 or 3 I don’t Know how to explain it to you
here the code that I made check it out and you will have a better idea
i own a arduino uno and for that reason im using analog pin like digital
the display is 20x4
and keypad 4x4

#include <Keypad.h>
#include <Servo.h>
#include <LiquidCrystal.h>
Servo servo1,servo2,servo3;
LiquidCrystal Lcd(13,12,11,10,A3,A4);
const byte fil=4;
const byte col=4;
char teclado[fil][col]={{'1','2','3','A'},{'4','5','6','B'},{'7','8','9','C'},{'*','0','#','D'}};

byte pines_fil[4]={9,8,7,6};
byte pines_col[4]={5,4,3,2};

Keypad customKeypad = Keypad( makeKeymap(teclado), pines_fil, pines_col, fil, col); 
String value="";
String angle="";
int i;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  servo1.attach(A0);
  servo2.attach(A1);
  servo3.attach(A2);
  Lcd.begin(20,4);
  Lcd.print("Bienvenidos");
  delay(2000);
  Lcd.clear();
  Lcd.print("Press D to start");
}

void loop() {

  int numero; 
  char customKey = customKeypad.getKey();
  if(customKey=='D')
  {                      
    Lcd.setCursor(0,0);
    Lcd.print("Num y D to move:");
    Lcd.setCursor(0,1);
    Lcd.print("1=S1 2=S2 3=S3");
    Serial.print("value: ");
    Serial.println(value);
    numero=value.toInt();
    if(numero==1) 
    {
      Lcd.clear();
      Lcd.print("ingre ang entre");
      Lcd.setCursor(0,1);
      Lcd.print("0 y 180=");
      int pos=value.toInt();
      servo1.write(pos);
      value = "";
    }
    if(numero==2) 
    {
      Lcd.clear();
      Lcd.print("ingre ang entre");
      Lcd.setCursor(0,1);
      Lcd.print("0 y 180=");
      int pos=value.toInt();
      servo2.write(pos);
      value = "";
    }
    if(numero==3) 
    {
      Lcd.clear();
      Lcd.print("ingre ang entre");
      Lcd.setCursor(0,1);
      Lcd.print("0 y 180=");
      int pos=value.toInt();
      servo3.write(pos);
      value = "";
    }    
   }

  if(customKey && customKey!='D')
  {         
    value=value+String(customKey);   
    //Serial.println(value); 
  } 
  delay(50);
  /*if (keypressed != NO_KEY)
   {
   Serial.println(keypressed);
   Serial.println(keypressed);
   }*/
}




Hi alcarak,

One of the first lessons you'll need to learn is the value of indentation and formatting. Please format your code (CTRL-T) and take a look at where the { }'s line up.

Your check for numero==1 is within the check for customKey == D, but the checks for numero==2, 3, etc. is outside of that if { } pair.

Also, the following code is after the final } in the loop function:

if (customKey && customKey != 'D')
{
  value = value + String(customKey);
  //Serial.println(value);
}
delay(50);

I'm not even sure what you posted will compile. Please fix this and re-post the code so we can get a better look at what you've got.

Thanks, Pat.

Hi look dont understand what you mean im noob yet but the program run till we need to enter the angle the program return to first menu and do nothing