Tengo una pregunta simple que me detiene.
Este programa ejecuta un error, aumenta "x" y muestra el resultado en la pantalla, pero ...
// LCD module connections
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
void main(){
int x = 0;
char txt[255];
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "Total:");
Lcd_Out(2, 1, "$");
while(1){
IntToStr(x, txt);
Lcd_Out(2, 11, txt);
x++;
Delay_ms(100);
}
}
Cuando agrego el código de configuración para tener 4 entradas en PORTA:
// LCD module connections
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
void main(){
TRISA = 0B00001111;
CMCON = 0B00000111;
ADCON1 = 0X0F;
PORTA = 0;
int x = 0;
char txt[255];
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "Total:");
Lcd_Out(2, 1, "$");
while(1){
IntToStr(x, txt);
Lcd_Out(2, 11, txt);
x++;
Delay_ms(100);
}
}
aparece el siguiente error:
Expresión no válida en la línea "int x = 0;"
Por favor, ayuda!