How to use BUTTON command right?


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Try this

    Is this wht your after try it and lets us know
    it uses 1 button to turn led on/off

    led1_status var bit
    button1 var portb.0
    led1 var portb.1
    main:
    if button1 = 1 then ' if the button is pressed

    if led1_status = 1 then ' if its last state was 1

    led1_status = 0 ' make it 0
    low led1
    pause 500 'debounce

    else

    led1_status = 1 ' the last state was a 0 so now make it a 1
    high led1
    pause 500 'debounce

    endif

    endif


    chuck

  2. #2
    Join Date
    Nov 2005
    Posts
    51


    Did you find this post helpful? Yes | No

    Default opps!

    I see that i missed the goto main of at the end

    i see that Tissy replied beofre me that must have been while i went and add a coffie but at least you have got to ways of doing it now

    chuck

  3. #3
    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    31


    Did you find this post helpful? Yes | No

    Smile Thanks

    Hi,

    Thanks to Tissy and Chuck for your examples.

    I can conclude that you don't use the BUTTON command when you "read" a switch.
    I just thought that it was possible to set up all the parameters with the BUTTON command.

    But I think that your examples teach me that using IF - THEN and GOTO or WHILE - WEND gives me much better possibilities.

    Gert
    *Let's do it*

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  2. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  3. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  4. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06
  5. Button subfunction 16F628
    By Jųan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2005, 16:44

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