Página 1 de 1

MikroC - Contador

MensagemEnviado: 13 Jan 2010 11:12
por gilliard
:lol: Falae Rapaziada :lol:

Já sei oque vocês devem estar pensando..... Oque será que ele quer dessa vez, MEU DEUS !!!! rrsssssss :mrgreen:

Bom....

Estou fazendo aquele relóginho para meu quarto, lembra ?!?!?

Eu queria ajustar a hora da melhor forma possivel, então eu pensei, pensei, pensei e pensei, e não cheguei a conclusão nenhuma rrsssss BRINCADEIRA.

Eu criei um esquema com SWITCH e CASES, onde exibi no LCD os numeros, incrementando e decrementando,OK

Mas agora eu estou com outro problema, eu estou tentando fazer o seguinte.....

Quando eu estiver no meu da operação de ajustar a hora, quando eu apertar ( asterisco ), chame uma outra função.....

Mas dai, já tentei de varias formas, se eu fizer tecla='*' a rotina não funciona.

Vejam:

Código: Selecionar todos
void data

   unsigned char tecla;

            int cont;               // acumulador auxiliar

                //-------------------------------
                Lcd_custom_Cmd(Lcd_Clear); // Limpa o LCD 16x2 //
                Lcd_custom_out(1,1,"AJUSTE DATA");
                Delay_ms(20);
                //-------------------------------

      do {

     
      if (porta.f0 == 0) // Se apertar tecla que esta em porta.f0
      {
        cont ++; incrementa
        Delay_ms(200);
        Lcd_custom_cmd(LCD_CLEAR);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);}
       

      if (porta.f1 == 0) // Se apertar tecla que esta em porta.f1
      {
        cont --; // decrementa
        Delay_ms(200);
        Lcd_custom_cmd(LCD_CLEAR);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);}

      switch (cont)
      {
        case 0 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"0");break;
        Delay_ms(1000);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 1 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"1");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 2 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"2");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 3 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"3");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 4 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"4");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 5 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"5");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 6 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"6");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 7 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"7");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 8 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"8");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 9 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"9");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

        case 10 :
        lcd_custom_cmd(LCD_CURSOR_OFF);
        Lcd_custom_out(1,1,"AJUSTE DATA");
        lcd_custom_out(2,1,"10");break;
        Delay_ms(10);
        Lcd_custom_out(2,3,"/");
        Delay_ms(20);
        Lcd_custom_out(2,7,"/");
        Delay_ms(20);

      }

  }while(1);


}


Abraço a todos, e desejo a participação de todos

MensagemEnviado: 13 Jan 2010 12:15
por Sergio38br
Código: Selecionar todos
 
   ='*' ou =='*' //?? Ó duvida!!!


[ ]'s
Sergio

MensagemEnviado: 13 Jan 2010 13:38
por gilliard
Bom que eu saiba, a diferença é a seguinte:

='*' - É igual a '*'

=='*' Se for igual a '*'

Quais as sugestões pessoais !!!! Para eu experimentar aqui, para tentar solucionar meu problema ?!?!?

MensagemEnviado: 13 Jan 2010 14:23
por rudsomlima
Faz o seguinte: se pressionado os dois botões de uma vez só, chama a função que vc quer.
No seu caso: if(!porta.f0 & !porta.f1) chama_funcao();

MensagemEnviado: 13 Jan 2010 14:30
por Sergio38br
Entao qual tu usaste na função?? se um atribui valor ( = ) e outro é utilizado em comparação ( == )??

[ ]'s
Sergio

MensagemEnviado: 13 Jan 2010 17:20
por gilliard
Eu queria mesmo, substituir as teclas do porta.f0 e porta.f1 por tecla=='1' e tecla=='2'. Mas não esta funcionando, dai eu conseguiria, usar o tecla=='*' para chamar outra subrotina teste();

Será que tem como fazer isso ?!?!?

Estou chamando a subrotina, utilizando a tecla=='*', dessa forma.

E queria juntar a rotina abaixo, com a rotina dos switch e cases, que passei lá em cima, dai quando eu apertar o asterisco, chamaria a subrotina teste().

Código: Selecionar todos
do {
                    tecla=0;// limpa o valor atual do teclado

                while (tecla==0) tecla=teclado(); // Aguarda algo ser digitado
               
                if(tecla=='*'){ // Se for digitado *

                teste();        // Chama a subrotina teste()

                }
               
                    } while(1); // Faz isso eternamente


OBS: Pessoal, eu não quero de mão beijada, eu quero receber as sugestões, dai vou implementando aqui, dai eu posto o resultado.

Mas estou muito feliz, com as ajudas que estou recebendo.

Agradeço a todos !!!!

MensagemEnviado: 13 Jan 2010 19:42
por gilliard
:D Me ajudem pessoal !!!! :D

MensagemEnviado: 13 Jan 2010 20:17
por ze
tudo vai depender de como está o seu teclado e da sua teclado()

MensagemEnviado: 14 Jan 2010 09:55
por gilliard
Falae Rapaziada !!!!

Já resolvi o problema aqui, valew !!!!

MensagemEnviado: 14 Jan 2010 10:17
por fabim
num guento isso. kkkkkkkkkkkkkkkkkkkk


Vamo lá.

O QUE ERA.?