Hello all dear member I want to count how many time I did press the button, I couldn't get any good result and not really understand how the Mikroc work, it doesn't work as C language. please help?
There will be two signals associated with every key press: key press and key release. They will be useful to determine combination switch presses (combinations)- e.g., press shift key and while pressed, press key A and then release both). I suggest you count (number of) key release events.
With one button it should be easy. Are you using interrupts? Connect RB0 to Vcc via a 10K and connect to ground via the switch. If you have not much load on the CPU, just test with a simple loop read digital input for RB0. Can you get to this much correctly?
If you want to know the exact number of times key pressed (not press and hold), go for counter.
Configure your counter pin and connect to the switch, in this way you could read exact number of time. If go for normal GPIO then you may miss to count multiple times when key is pressed and hold.
For pic16f84a use RA4 pin configured as counter.
1.Set the bit T0CS to operate the TImer0 in counter mode
2. TMR0 will have the number of times keys pressed
additionaly you can enable Interrupt using GIE EEIE T0IE and T0IF if your counter value overflows
Thanks very much for your kindness. I really don't know how to use those things such as TMR0, but now it work by just add delay after if(PORTB.RB)==0); Thank very much!
You are ignoring the transition; if portB is held pressed, it will count multiple times. Increment count only when you see the transition. Your code is wrong as it appears.