Quote Originally Posted by turkuaz View Post
Hi Everyone.
I want to count microswich open-close positon to count disk rotation.
ı have a micro magnetic swich which is produce 2 signal when maghnetic disc rotating 1 time.magnetic swich debounce time is 20 uSec.
I use Pic16F877
This is my code:

..PORTA.4 input pin...
........
..........
loopHy:
IF PORTA.4 = 0 THEN loopHy
count = count+1
Lcdout $fe, $C0, #count:Pause 250(debounce time for slow rotation)
goto loopHy
........

is it Ok .or anybody give me advise.
Thanks.
I solve this problem myself as follows:
.............
loopHy:
IF PORTA.4 = 0 THEN loopHy
count = count+1
While portA.4=1 Then
Lcdout $fe, $C0, #count
Wend
goto loopHy
.............................
It is working nice
thanks everyone.