Programa en switch (Finite State Machine) Menú

switch(state)
      {
         case startState:
            state = activar;  break;
         case activar:

           if(kp==49)
            {
                  led();
               state = tiempos;
               Lcd_Cmd(_LCD_CLEAR);                     // Clear display
               Lcd_Cmd(_LCD_CURSOR_OFF);
               Lcd_Out(1, 7, "MENU");                // Cursor off
               Lcd_Out(2, 1, "    Activar>");
            }
            break;
            
            


         case tiempos:
            if(kp==50)
            {
            
               state = sirenas;
               Lcd_Cmd(_LCD_CLEAR);                     // Clear display
               Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
               Lcd_Out(1, 7, "MENU");                // Cursor off
               Lcd_Out(2, 1, "    <Tiempos>");

             }
            break;

           case sirenas:
            if(kp==50)
            {

               state = cambioclave;
               Lcd_Cmd(_LCD_CLEAR);                     // Clear display
               Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
               Lcd_Out(1, 7, "MENU");                // Cursor off
               Lcd_Out(2, 1, "   <Sirenas>");
            }
            break;



           case cambioclave:
            if(kp==50)
            {

               state = activar;
               Lcd_Cmd(_LCD_CLEAR);                     // Clear display
               Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
              Lcd_Out(1, 7, "MENU");                // Cursor off
              Lcd_Out(2, 1, " <Cambiar clave>");


            }
            break;


            default:   state = startState;        //if unknown state, reboot
            break;
      }




if (kp==68){

  Lcd_Cmd(_LCD_CLEAR);                     
   Lcd_Cmd(_LCD_CURSOR_OFF);
   Lcd_Out(1, 7, "OKEY");
   Delay_ms(2000);
}
}

Hola a todos.

Este es el código para un menú en un lcd. Todo marcha correcto, pero no ejecuta el subprograma led();

Seguramente sea porque el switch se queda en estado muerto, a ver si alguien sabe qué hacer.

Un saludo y muchas gracias por adelantado.
Un saludo! :wink:

Yo cuando tengo problemas así, uso el monitor serie para saber que valores tienen las variables, e intentar averiguar por que no hace lo que se supone que deberia hacer. saca el valor de state y de kp a la entrada del switch.