error in push button counter program

General discussion on mikroBasic.
Post Reply
Author
Message
kshitijnov
Posts: 4
Joined: 02 Feb 2016 14:18

error in push button counter program

#1 Post by kshitijnov » 10 Feb 2016 17:24

Below is a program for push button counter

sbit LCD_RS at RB4_bit; // LCD_RS assigned to PORT RB4;
sbit LCD_EN at RB5_bit; // LCD_EN assigned to PORT RB5;
sbit LCD_D4 at RB0_bit; // LCD_D4 assigned to PORT RB0;
sbit LCD_D5 at RB1_bit; // LCD_D5 assigned to PORT RB1;
sbit LCD_D6 at RB2_bit; // LCD_D6 assigned to PORT RB2;
sbit LCD_D7 at RB3_bit; // LCD_D7 assigned to PORT RB3;

sbit LCD_RS_Direction at TRISB4_bit; // LCD_RS assigned to TRIS B4;
sbit LCD_EN_Direction at TRISB5_bit; // LCD_EN assigned to TRIS B5;
sbit LCD_D4_Direction at TRISB0_bit; // LCD_D4 assigned to TRIS B0;
sbit LCD_D5_Direction at TRISB1_bit; // LCD_D5 assigned to TRIS B1;
sbit LCD_D6_Direction at TRISB2_bit; // LCD_D6 assigned to TRIS B2;
sbit LCD_D7_Direction at TRISB3_bit; // LCD_D7 assigned to TRIS B3;
// End LCD module connections

char Message1[]="LCD and Button";
unsigned int number = 0;

char *digit = "0000";

void Display_init()
{
digit[0] = number/1000 + 48;
digit[1] = (number/100)%10 +48;
digit[2] = (number/10)%10 + 48;
digit[3] = number%10 +48;
Lcd_Out(2,7,digit);
}

void main()
{
CMCON0 =0x07;
TRISA6_bit = 1;
TRISA7_bit = 1;
PORTA = 0;
TRISB = 0;
PORTB = 0;

Lcd_init();
Lcd_cmd(_LCD_CLEAR);
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_out(1,2,Message1);

while(1)
{
if(Button(&PORTA,4,1,0))
{
Delay_ms(200);
number = number +1;
}
if(Button(&PORTA,6,1,0))
{
Delay_ms(200);
number = number -1;
}
if (number > 9999u)
number = 0;
display_init();
}
} `

It shows an error:- End of file expected but '`' found pushcounter.c
in line 60 which is the ast line where scope of main ends

checker
Posts: 77
Joined: 22 May 2011 10:58

Re: error in push button counter program

#2 Post by checker » 15 Feb 2016 12:11

**** wrote:Below is a program for push button counter
}
} `<----
It shows an error:- End of file expected but '`' found pushcounter.c
in line 60 which is the ast line where scope of main ends

try getting rid of the "`" character in red... the error is in the line number, in this case the last line and last character

Post Reply

Return to “mikroBasic General”