Help to complete the this code

Post your requests and ideas for the mikroElektronika website & forums.
Post Reply
Author
Message
sula91
Posts: 1
Joined: 15 May 2011 14:30

Help to complete the this code

#1 Post by sula91 » 15 May 2011 14:45

Hi! I need help to complete this program writed with mikroc. I have bild something like a menu so i want create a function, so when i press a botton this reset all the function end send me to the main.
I am new in this world so i hope you can help me. Thanks

Code: Select all

char volt[13];//vettore della lunghezza di stringa "floattostr"
char *text;  //variabile per caratteri alfanumerici
float lettura; //variabile per elaborare con numeri decimali
unsigned int i, b;

sbit LCD_RS at RB2_bit; //assegnazione portb al display
sbit LCD_EN at RB3_bit; //
sbit LCD_D4 at RB4_bit; //
sbit LCD_D5 at RB5_bit; //
sbit LCD_D6 at RB6_bit; //
sbit LCD_D7 at RB7_bit; //

sbit LCD_RS_Direction at TRISB2_bit;//assegnazione portb al display
sbit LCD_EN_Direction at TRISB3_bit;//
sbit LCD_D4_Direction at TRISB4_bit;//
sbit LCD_D5_Direction at TRISB5_bit;//
sbit LCD_D6_Direction at TRISB6_bit;//
sbit LCD_D7_Direction at TRISB7_bit;//

void main(){
            char k;
            unsigned char a,a1;
            intcon=0;      //parametri per la lettura analogica
            adcon0=0x0b;   //
            adcon1=0x7f;   //
            trisa=0x1f;
            lcd_init();
                                              while(1){
                                                       if ((ra0_bit)&&(k==0)){ a=1;
                                                                              k=1;
                                                                              }
                                                                         switch(a){
                                                                                     default:
                                                                                          lcd_cmd(_lcd_cursor_off);
                                                                                          delay_ms(200);
                                                                                          lcd_cmd(_lcd_clear);
                                                                                          Lcd_Out(1,1,"MENU':");
                                                                                          Lcd_out(2,3,"1.Illuminazione");
                                                                                          lcd_out(3,3,"2.Riscaldamento") ;
                                                                                          Lcd_out(4,3,"3.Altre funzioni");
                                                                                     break;
                                                                                     case 1:
                                                                                          lcd_cmd(_lcd_cursor_off);
                                                                                          delay_ms(200);
                                                                                          lcd_cmd(_lcd_clear);
                                                                                          Lcd_out(1,1,"Illuminazione:");
                                                                                          lcd_out(2,1,"1. Zona 1");
                                                                                          lcd_out(3,1,"2. Zona 2");
                                                                                          lcd_out(4,1,"3. Zona 3");
                                                                                          if ((ra0_bit)&&(k==1)){ a1=11;
                                                                                                                  while ((ra0_bit)&&(k==1)){};
                                                                                                                 }
                                                                                          if (ra1_bit) a1=12;
                                                                                          if (ra2_bit) a1=13;
                                                                                                                switch(a1){
                                                                                                                          case 11:
                                                                                                                          lcd_cmd(_lcd_cursor_off);
                                                                                                                          lcd_cmd(_lcd_clear);
                                                                                                                          delay_ms(200);
                                                                                                                          lcd_cmd(_lcd_clear);
                                                                                                                          Lcd_out(1,1,"Zona 1:");
                                                                                                                          lcd_out(2,1,"1. Cucina");
                                                                                                                          lcd_out(3,1,"2. Soggiorno");
                                                                                                                          lcd_out(4,1,"3. Back");
                                                                                                                          break;
                                                                                                                          case 12:
                                                                                                                          lcd_cmd(_lcd_cursor_off);
                                                                                                                          delay_ms(200);
                                                                                                                          lcd_cmd(_lcd_clear);
                                                                                                                          Lcd_out(1,1,"Zona 2:");
                                                                                                                          lcd_out(2,1,"1. Camera 1");
                                                                                                                          lcd_out(3,1,"2. Camera 2");
                                                                                                                          lcd_out(4,1,"3. Back");
                                                                                                                          break;
                                                                                                                          case 13:
                                                                                                                          lcd_cmd(_lcd_cursor_off);
                                                                                                                          delay_ms(200);
                                                                                                                          lcd_cmd(_lcd_clear);
                                                                                                                          Lcd_out(1,1,"Zona 3:");
                                                                                                                          lcd_out(2,1,"1. Corridoio");
                                                                                                                          lcd_out(3,1,"2. Bagno");
                                                                                                                          lcd_out(4,1,"3. Back");
                                                                                                                          break;
                                                                                                                          
                                                                                                                         }

                                                                                     break;



                                                                                    }
                                              }
            }

Post Reply

Return to “Website & Forums Wishlist”