Ir ao conteúdo
  • Cadastre-se

Não está acontecendo o que eu quero na Programação!


Posts recomendados

A minha programão consiste em :
Botão 1 (Ra01 ) Escrevera uma frase
Botão 2 (Ra03 ) Escrevera uma frase, e tira a primeira
Botão 3 (Rb0 ) Volta ao menu

O problema que estou enfrentando é que ao ligar o circuito já aprece algo e deveria aparecer nada, só deveria aparecer se eu apertar o botão!

char comandageral = 0;


//Lcd pinout settings //SAIDAS QUE EU USAREI! AQUI N estão AS PORTAS RA NEM RD
//AQUI ESTÁ A COMUNICAÇÃO DAS PORTAS DO "LCD" COM AS PORTAS DO "PIC"
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;

// Pin direction // SAIDAS QUE EU USAREI! AQUI N estão AS PORTAS RA NEM RD
//AQUI ESTÁ A COMUNICAÇÃO DAS PORTAS DO "LCD" COM AS PORTAS DO "PIC"
//OCILA AS PORTAS DO LCD COM O MICROCONTROLADOR
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;

#define LE RA1_bit
#define LG RA3_bit
#define LN RB0_bit

void main() {

//TRISB.B0 = 1; //(BOTÃO C QUE VOLTA PARA O MENU DE FRASES)

TRISC.B2 = 0;
PORTC.B2 = 0;
TRISC.B3 = 0;
PORTC.B3 = 0;
TRISC.B4 = 0;
PORTC.B4 = 0;
TRISC.B5 = 0;
PORTC.B5 = 0;
TRISC.B6 = 0;
PORTC.B6 = 0;
TRISC.B7 = 0;
PORTC.B7 = 0;

/* FALTA A SAIDA RD, QUE SERA PARA A TEMPERATURA E O BOTÃO QUE A FARA
APARECER JUNTO COM A DATA! */


ADCON1 = 15; //DEFINE COMO PORTAS DIGITAIS
//TRISA.A0 = (BOTÃO MENU DE FRASES) FALTA SE ELA VAI LIGADA OU NÃO
TRISA.B1 = 1;
TRISA.B3 = 1;
//TRISA.A2 = 0; (SAIDA RD) SAIDA DE TEMPERATURA
Lcd_Init(); //LCD INICIADO!
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Olá Amor!"); // PRIMEIRA FRASE COMO VAI INICAR E DEPOIS IR PRO MENU
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);



while (1) {

comandageral = 1;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,6,"FRASE 1"); // Escreve no Display
Lcd_Out(2,6,"FRASE 1"); // Escreve no Display
// Limpa o Display
delay_ms(500);

if(LE == 0X00){

Lcd_Cmd(_LCD_CLEAR); // Limpa o Display

while (comandageral == 1) {

Lcd_Out(1,6,"FRASE 1"); // Escreve no Display
delay_ms(50);

if( LN == 0) comandageral = 0;

}
}

else if(LG == 0X00){

Lcd_Cmd(_LCD_CLEAR); // Limpa o Display

while (comandageral == 1) {

Lcd_Out(1,6,"FRASE 2"); // Escreve no Display
delay_ms(50);

if( LN == 0) comandageral = 0;

}
}
}
}


Então desde já agradeço e qualquer sugestão podem mandar também obrigado!

Link para o comentário
Compartilhar em outros sites

  • Membro VIP

Seu programa tá 1/2 estranho. Melhore a identação dele, selecione e clique o botão "code" acima pra facilitar  a análise. Mas geralmente pra esperar uma tecla ser pressionada faço isso:

while(RA1);while(!RA1);//p.ex.

Atenção aos TRIS´s

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...