12f675_fuse_about_to_blow!


Results 1 to 40 of 929

Threaded View

  1. #27
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Not quite sure I understand. Are you saying that you want it to execute one of the three loops depending on how many times the butten is pressed within a certain amount of time? Or are you saying that you want to execute the three loops, one after the other, but to wait for a button press between the loops?

    In any case, I'm afraid what you have there ain't gonna work....

    Code:
    B_P_C VAR WORD
    COUNT GPIO.5, 10000, P_B_C
    The above will define a 16 bit variable called B_P_C and then immediatley start counting how many times the button connected to GPIO.5 is pushed. It will keep counting for 10 seconds (10000mS) after which it continues in the program.

    Code:
    Let i = B_P_C
    What this does is to say that i should be assigned whatever value B_P_C is. So, after this is exectued i has the same value as B_P_C, provided i is declared the same size as B_P_C - a WORD in this case.

    Code:
    IF B_P_C = i GOTO  FIRSTLOOP ' Button pressed once
    IF B_p_c = i+i GOTO SECONDLOOP ' Button pressed twice
    IF B_P_C = i+i+i Goto THIRDLOOP   ' Button pressed a third time
    Now, since i is the same as B_P_C (it is because you told it to be) the only condition that can ever be true is the first one.

    /Henrik.

    PS. Pushbuttons are quite "bouncy", the COUNT command may register several counts even though you only push the button once.
    Last edited by HenrikOlsson; - 2nd March 2010 at 17:32.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts