LED ON and OFF with 2 Push button switches


Closed Thread
Results 1 to 16 of 16

Hybrid View

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


    Did you find this post helpful? Yes | No

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

    Hi,
    Read thru your mainloop, line by line, and try to figure out what's happening.

    You check if PB is pressed, if it is you turn on the LED - that's fine. But if PB isn't pressed you turn off the LED - that's not what you want, is it?
    Do you have the two switches wired the same way? I ask because you check PB for a logic 1 while you check PB1 for a logic 0 - that's all fine if it's the way you have it wired, don't forget pullup/pulldown resistors though.
    Finally, the comments are somewhat confusing because at one place you say that LOW LED turns the LED on while in another place you say that LOW LED turns the LED off - I don't know which is correct.....

    /Henrik.

  2. #2
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

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

    LED CON 0 doesn't clearly map the LED to a pin.

    LED VAR GPIO.0 does. Just easier to understand.


    I like to put a pinout connection diagram for the chip as a reminder what is connected to what. It also helps when asking a question.
    Similar to this example

    Code:
    ;
    ; Target Controller -      PIC16F628A 
    ;                                  __________  
    ;                       d6--RA2 |1       18| RA1--d5
    ;                       d7--RA3 |2       17| RA0--d4
    ;              LED-------RA4 |3       16| OSC1--------
    ;     +5V-----------!MCLR |4       15| OSC2--------
    ;     Ground----------Vss |5       14| VDD---------+5 V
    ;              gps in-----RB0 |6       13| RB7--------- 
    ;                         ---RB1 |7       12| RB6--------- 
    ;                         ---RB2 |8       11| RB5--e
    ;                   pbutt--RB3 |9       10| RB4--rs
    ;                                     ----------
    Last edited by tasmod; - 28th April 2014 at 13:33.
    Rob.

    The moment after you press "Post" is the moment you actually see the typso

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 : 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