dear all,
the problem with the code is that when i press the switch at C0 it displays the count but wen i press switch at B0 it doesnt go out of the previous loop and still displays the count. i want that wen C0 is pressed it shud display the count and wen B0 is pressed it should clear the count and only display the text.
plz help me in this code
That is what your code does so it must be something else. Try posting complete code and include which chip you are using. Note, it may take up to 1 second before it changes due to the delay.
BTW, when you post code type
Code:
before it and
after it so it keeps it's formating like this,
Code:
int i ;
char txt[5];
void main(){
i = 0;
PORTB = 0;
TRISB = 0b00000001;
PORTC = 0;
TRISC = 0b00000001;
PORTD = 0;
LCD_Config(&PORTD,1,0,2,7,6,5,4); // LCD pins that are connected to PIC at PORTD
while(1){
if (!PORTC.F0 == 1){
i=i+1;
Lcd_Cmd(Lcd_CLEAR);
Lcd_Cmd(Lcd_CURSOR_OFF);
IntToStr(i, txt);
Lcd_Out(2,2 ,txt);
delay_ms(1000);
}
if(!PORTB.F0 == 1){
Lcd_Cmd(Lcd_CLEAR);
Lcd_Cmd(Lcd_CURSOR_OFF);
LCD_Out(1,1, "DINNAR BOX");
LCD_Out(2,1,"FOR HAJJ!");
}
}
}
thanks for reply Mike.
i am using PIC 16F877A... i think there is problem with the integer to string conversion...i tried another code. the switches are working but when count button is pressed it displays the following ...
coin dropped = $ (some symbolic values and keeps on changing)
It is doing what you have told it to do, display character i where i goes from 0 to 255 and so it displays all the ascii characters. What you need is a function like atoi() - look it up in the help file.
i have problem with my code again
i make a program in which, when switch at B0 is pressed it will display count and when switch B0 is off it will display welcome text. the problem is that for my coin counter hardware to run correctly i have to reduce the delay to 20ms in the if statement(the welcome text display ).as i do so the welcome display, which is meant to scroll as per my code, scrolls very fast and cant be seen. is there any way to reduce the delay so that it can count coins and display the welcome text...
plz help ...its my project...