Help on routine-Work with a button


Results 1 to 12 of 12

Threaded View

  1. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    or even my nooby 'take' might work?.

    Code:
    Main:
    if sw1=0 then 
    pause 3200             ' wait 3.2 seconds (or whatever length of time you expect the user to press/hold the switch for)
    if sw1 = 0 then       ' recheck to see if sw1 is still held down
    goto label2            ' if it is then go & do some stuff in label2
    else
    goto label 1           ' if it wasn't held down then go & do other stuff -  goto label 1
    endif
    endif
    pause 10
    goto main
    
    label1:
    do stuff!
    pause 20           ' bit of a pause for switch debouncing
    goto main
    
    label2:
    do other stuff!
    pause 20 '           ' bit of a pause for switch debouncing
    goto main
    Of course with the method I've posted above, you have to hang around 3.2 seconds to work out whether the user input wanted label1 or label2 - it would really works betterif there was just say a half second pause to decide/glean if label1 or label 2 was required. (but if you're new to picbasic it means grappling with less commands/concepts!)

    Disclaimer: I know bo-diddley squat really!!
    Last edited by HankMcSpank; - 17th August 2010 at 15:34.

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