HELP! I have a program but it doesn't work

My program consist on an interface to automate a home, everything seems to be ok, but when i choose the option of turning off the lights in the programation it didn't work, i need some help and i would like someone to recomend me some things to improve this work, thanks a lot.
This is the program:

#include <Keypad.h>  
#include <LiquidCrystal.h>  
//LED  
int led_rojo = 1;  
int led_verde = 0;
int led_azul =2;
int led_ama =3;
//Teclado  
const byte TAM_COLS = 4;  
const byte TAM_FILS = 4;    
byte COLUMNAS[TAM_COLS] = {17,16,15,14 };  
byte FILAS[TAM_FILS] = {21, 20, 19, 18};    

char keys[TAM_FILS][TAM_COLS] = {  
{ '1','2','3','A' } ,  
{ '4','5','6','B' } ,  
{ '7','8','9','C' } ,  
{ '*','0','#','D' }  };    
char idioma;    
Keypad teclado = Keypad (makeKeymap(keys), FILAS, COLUMNAS, TAM_FILS, TAM_COLS);  
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); //Pins LCD     
void setup()
{  
Serial.begin(9600);  
lcd.begin(16,2);    
pinMode(led_rojo, OUTPUT);  
pinMode(led_verde, OUTPUT);    
pinMode(led_azul, OUTPUT);
pinMode(led_ama, OUTPUT);
}    
void loop()
{
menu_idioma();  
char tecla = teclado.getKey();  
Serial.println("Tecla Idioma");    

switch (tecla)
{  
case '1':  idioma = 'N';  
menu_ingles();  
menu();  tecla = ' ';
break;  

case '2':  idioma = 'S';
menu_espanol();
menu();
tecla = ' ';
break;  
}    

}      

void menu()
{  
char tecla1;
do{
tecla1 = teclado.getKey();  
Serial.println("Tecla Menu 2");    
switch (tecla1)
{  
case '1':  
submenu();  
encender_luces();  
break;  

case '2':  
submenu();  
apagar_luces();  
break;  

case '3':  
mostrar_temperatura();  
break;  
}  
}  
while(tecla1 != '4' );  
}    
void menu_idioma(){
lcd.clear();  
lcd.print("1.English");  
lcd.setCursor(0, 1);  
lcd.print("2.Espanol");  
}    
void menu_espanol()
{
lcd.setCursor(0, 0);
lcd.print("** BIENVENIDO **");
lcd.setCursor(0, 1);  
lcd.print("****************");  
delay(1500);    
lcd.clear();  
lcd.setCursor(0, 0);  
lcd.print("1.Encender luces");  
lcd.setCursor(0, 1);  
lcd.print("2.Apagar luces");  
delay(1500);    
lcd.clear();  
lcd.setCursor(0, 0);  
lcd.print("3.Temperatura");  
lcd.setCursor(0, 1);  
lcd.print("4.Salir");  
}    
void menu_ingles(){    
lcd.setCursor(0, 0);  
lcd.print("*** WELCOME ***");  
lcd.setCursor(0, 1);  
lcd.print("****************");  
delay(1500);    
lcd.clear();  
lcd.setCursor(0, 0);  
lcd.print("1.LED ON");  
lcd.setCursor(0, 1);  
lcd.print("2.LED OFF");  
delay(1500);    
lcd.clear();  
lcd.setCursor(0, 0);  
lcd.print("3.Temperature");  
lcd.setCursor(0, 1);  
lcd.print("4.Exit");  
}    
void submenu(){  
switch (idioma){  

case 'N':  
submenu_ingles();  
break;  

case 'S':  
submenu_espanol();  
}  
}    
void submenu_ingles()
{  
lcd.setCursor(0, 0);  
lcd.print("1.Red 2.Green");  
lcd.setCursor(0, 1);  
lcd.print("3.All 4.Exit");  
}    
void submenu_espanol()
{  
lcd.setCursor(0, 0);  
lcd.print("1.Rojo 2.Verde");  
lcd.setCursor(0, 1);  
lcd.print("3.Todo 4.Salir");  
}    
void encender_luces()
{  
char tecla2;  
do{  
tecla2 = teclado.getKey();  
Serial.println("Tecla Submenu Encender");    
switch (tecla2)
{  
case '1':  
encender_rojo();  
break;  
case '2':  
encender_verde();  
break;  
case '3':  
encender_rojo();  
encender_verde();  
break;  
case '4':  
switch (idioma) 
{  
case 'N':  
menu_ingles();  
break;  
case 'S':  
menu_espanol();  
break;  
}  
}  
}  
while(tecla2 != '4' );  
}    
void apagar_luces()
{  
char tecla2;  
do{  
tecla2 = teclado.getKey();  
Serial.println("Tecla Submenu Apagar");    
switch (tecla2)
{  
case '1':  
apagar_rojo();  
break;  
case '2':  
apagar_verde();  
break;  
case '3':  
apagar_rojo();  
apagar_verde();  
break;  
case '4':  
switch (idioma) 
{
case 'N':  
menu_ingles();  
break;  
case 'S':  
menu_espanol();  
break;  
}  
}  
}  
while(tecla2 != '4' );  
}    
void encender_rojo()
{  
digitalWrite(led_rojo,HIGH);  
}    
void encender_verde()
{  
digitalWrite(led_verde,HIGH);  
}    
void apagar_rojo()
{  
digitalWrite(led_rojo,LOW);  
}    
void apagar_verde()
{  
digitalWrite(led_verde,LOW);  
}    
void mostrar_temperatura()
{  
char tecla2;  
do{  
tecla2 = teclado.getKey();  
obtener_temperatura();  
if (tecla2 == '4')
{  
switch (idioma) 
{  
case 'N':  
menu_ingles();  
break;  
case 'S':  
menu_espanol();  
break;  
}  
}    
}  
while(tecla2 != '4' );  
}    
void obtener_temperatura()
{  
lcd.setCursor(0, 0);  
lcd.print(" C");    
lcd.setCursor(0, 1);  
switch (idioma)
{  
case 'N':  
lcd.print("4.Exit");  
break;  
case 'S':  
lcd.print("4.Salir");  
break;  
}      
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Post your code between code tags (use the # key above the smileys).
Get rid of your delay()s. Use the 'blink without delay' example in the IDE.

My first suggestion is the same of Henry_Best.
The second is that you must use identation (the easy way to do that is to chose the option autoformat of the menu tools or press the Ctrl+T).
The third is that you can do the change between languages very easily using 2 arrays one with the messages in Spanish and other with the messages in English.

After that, I don't understand very well in which place you have the problem. You reach the function void encender_luces()? Is here the error or is in other place?

Posting over 100 lines of code and just saying "it didn't work" is not helpful.

You didn't provide a very good explanation of what you are trying to do. "Automate a home" is awfully vague. Then you say you tried to turn off the lights and "it didn't work."

Please edit your post to put your code in code tags, and with proper formatting.

Also tell us which section of your code you are having trouble with, what you have tried, and in detail how it's failing to do what you want. Don't expect your readers to wade through a big pile of code, figure out what you are trying to do, figure out what's wrong with what you are trying to do, and give you solutions.

Invest at least as much effort in asking your question as the effort you are asking from your readers. If you invest a few seconds of effort in asking a vague, sloppy question, and ask minutes or hours of effort in return then it's not fair to us, and we're not going to want to help you.

Also, your code uses Spanish variable names and display text. That makes following it much harder for non Spanish speakers. Adding comments in English (the main language of this forum) would be a big help to your readers.

This is an example of "spaghetti code"

you need to organize the code a little more.

also, please give us your error log.

TheTurtleKing:
This is an example of "spaghetti code"

you need to organize the code a little more.

This Thread may help.

...R