Olá pessoal!
Boa tarde a todos!
Estou desenvolvendo um programa no PIC16F887, mas estou tendo um problema ao tentar controlar um botão.
Utilizei um LCD 20x4 e coloquei mais outros botões para iniciar o projeto, queria ao menos conseguir ligar um LED com um destes botões, mas, por alguma razão, o LED não liga. Alguém poderia me ajudar a entender onde eu poderia estar errado ?
//=============================================================================
//
// Microcontrolador - PIC16F887 [ CLP / PIC 40 ]
// Cristal Oscilador: HS, 8.0000 MHz
// TRISB / PORTB ==> Utilizado para Controle do LCD 20x4; ( Configurar como saída )
// TRISD / PORTD ==> Configurar como ENTRADA Digital;
//=============================================================================
//================= Configuração LCD =========================================
// LCD module connections
sbit LCD_RS at RB4_bit; // RS no RB4;
sbit LCD_EN at RB5_bit; // EN no RB5;
sbit LCD_D4 at RB0_bit; // D4 no RB0;
sbit LCD_D5 at RB1_bit; // D5 no RB1;
sbit LCD_D6 at RB2_bit; // D6 no RB2;
sbit LCD_D7 at RB3_bit; // D7 no RB3;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
//============= Fim da Configuração LCD =====================================
//============= Variáveis Globais ===========================================
#define Botao_1 RA1_bit
#define Botao_2 RA2_bit
#define LED1 RC1_bit
// =================== PROGRAMA PRINCIPAL ====================================
void main() // Inicio do Programa Principal
{
//==================== REGISTRADORES DO PIC ==================================
ANSEL = 0; // Configurar ANALOG pinos como Digital;
ANSELH = 0;
C1ON_bit = 0; // Desliga os Comparadores;
C2ON_bit = 0; // Desliga os Comparadores;
//=================== FIM DOS REGISTRADORES/COMPARADORES ======================
// ================= Configuração dos Pinos I/O =============================
// ============ Configuração Botões ======
// 0b76543210
TRISA = 0b00001110; // Configura TRISA 1; TRISA 2 e TRISA 3 como entrada;
PORTA = 0b00001110; // Configura todo o PORTA para iniciar desligado;
//=============================
TRISC = 0b00000010; // Configura TRISC1 como saída
PORTC = 0b00000010; // Configura PORTC1 para iniciar desligado
//======= Registradores do LCD ==========
TRISB = 0b00000000; // Configura TRISB como saída;
PORTB = 0b00000000; // Configura PORTB para iniciar desligado;
//=======================================
//===================== Fim da Configuração ==================================
//=================== Configuração do LCD ====================================
Lcd_Init(); // Inicializa o LCD;
Lcd_Cmd(_LCD_CLEAR); // Limpa a Tela do Display;
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor OFF(Desligado);
Lcd_Out(1,1,"Inicializando..."); // Escrever o texto;
Lcd_Out(1,2,"...");
delay_ms(1000); // Delay de 1000 Mili-Segundos;
lcd_cmd(_LCD_CLEAR); // Limpa a Tela do Display;
//====================== Fim da configuração do LCD ==========================
LED1 = 0;
Botao_1 = 1;
Botao_2 = 0;
ENTER = 0;
if(Botao_1 == 0);
{
LED1 = 1;
}
} //============= FIM DO PROGRAMA PRINCIPAL ==================================