muza1988
Newbie level 5
dear all,
i want to make a program that when B0 is pressed it should display the count on LCD and wen B1 is pressed it should clear the count and display the text message. the problem with my code is that it displays the count wen i press B0 (switch at B0) but wen i press B1 it doesnt exit the previous loop and still it displays the count on the LCD.
plz help me i am new to mikroC
i want to make a program that when B0 is pressed it should display the count on LCD and wen B1 is pressed it should clear the count and display the text message. the problem with my code is that it displays the count wen i press B0 (switch at B0) but wen i press B1 it doesnt exit the previous loop and still it displays the count on the LCD.
plz help me i am new to mikroC
Code:
int i;
char txt[5];
void main()
{
i = 0;
PORTB = 0;
TRISB.F0 = 1; //PORT B0 as input // RB0 as input switch
TRISB.F1 = 1; //PORT B1 as input switch 2
TRISB.F2 = 0; //PORT B2 as Output
TRISB.F3 = 0; //PORT B3 as Output
TRISB.F4 = 0; //PORT B4 as Output
TRISB.F5 = 0; //PORT B5 as Output
TRISB.F6 = 0; //PORT B6 as output
TRISB.F7 = 0; //PORT B7 as output
PORTD = 0;
LCD_Config(&PORTD,1,0,2,7,6,5,4); // LCD pins that are connected to PIC at PORTD
while(1)
{
LCD_Cmd(LCD_CLEAR);
LCD_Out(1,1, "DINNAR BOX"); // Print text to LCD, 1st row, 1st column
Delay_ms(1000);
LCD_Out(2,1,"FOR HAJJ!");
if(PORTB.F0 == 1) // ! coz its input low thats
{
i=i+1;
IntToStr(i, txt);
Lcd_Out(2,2 ,txt);
Delay_ms(1000);}
if(PORTB.F1 == 1)
{
LCD_Out(1,1, "DINNAR BOX"); // Print text to LCD, 1st row, 1st column
Delay_ms(1000);
LCD_Out(2,1,"FOR HAJJ!");}
} // for while
} // for void