LED ON and OFF with 2 Push button switches


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    Have a look to Microchip DS 40040 ... ( tips and tricks for 8 pins ...)

    solutions are there !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    Thanks for reminding me about that document. Tons of useful information.

  3. #3
    Join Date
    Sep 2015
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    Hi Acetronics2 and AvionicsMaster1,
    Would either of you guys please post the .pdf for DS40040 from Microchip. It sounds like a must have document, but I cannot find it on Microchip's website.
    Thank you.
    Regards,
    mike

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches


  5. #5
    Join Date
    Sep 2015
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    Hi fratello,
    Thanks for the link.
    Regards,
    mike

  6. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    It’s a flip-flop, so if you do it in software a flip-flop might as well be 1 bit of memory.
    You’re going to want to look a the LED in a real program and know if it’s on or off,
    so will usually want to store the LED state which would usually represent some program state.

    Code:
    flipflop var bit ‘ 1 = LED is on 0 = LED is off
    debounce var byte ‘ button debounce counter
    flipflop = 0 ‘ start with LED off at power up, or on if you want to
    debounce = 0 ‘ reset debounce counter
    
    trisb.0 = 1’ button pin input
    trisb.7 = 0’ LED pin output
    
    cycle: 'program cycle
    
    if debounce > 199 then
    if portb.0 = 1 then
    flipflop = 1
    debounce = 0
    else
    flipflop = 0
    debounce = 0
    endif
    endif
    
    if flipflop = 1 then ‘ set LED to flip flop state
    portb.7 = 1
    else
    portb.7 = 0
    endif
    
    if debounce < 200 then ‘ increment button debounce counter
    debounce = debounce + 1
    endif
    
    goto cycle ‘ repeat loop forever

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: LED ON and OFF with 2 Push button switches

    But that's only using 1 button Art not 2 as in the title of the thread.....
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. Push button on PIC16F887
    By menta in forum General
    Replies: 21
    Last Post: - 25th June 2008, 07:47
  2. 12f629 push button & LED
    By yankee in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th February 2006, 01:45
  3. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06
  4. push button problem
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd June 2005, 19:44
  5. Push Button 'Menu' to Choose Variable.
    By Tissy in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th March 2005, 07:00

Members who have read this thread : 1

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