Having no idea what your circuit looks like, my first guess is your button is bouncing. So when you press it, the pic sees any number of presses during that short time between starting to make contact and fully pressed. To test, add a pause in the "test" :
TEST:
pause
cnt = cnt + 1
IF cnt = 3 THEN OFF_MOSFET
GOTO CHECK
I don't know the exact format of pause, but set it for something big like 100mS. That way for every button press, execution waits to allow your finger to catch up with the pic.
Bookmarks