Newbie question about switch + led


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    16

    Default Newbie question about switch + led

    Code:
    start:
    input porta.3   
    low portc.0      
    If porta.3 = 1 then led   ' when switch is pressed it goes to label "led" right?
    goto start
    
    led:
    high portc.0    'here should the led light up?
    pause 100
    goto start
    end
    It happens NOTHING with this code.
    If i change the value to "If porta.3 = 0 then led" the led always lights up except when switch is pressed down.
    Any suggestions?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mradde View Post
    Code:
    start:
    input porta.3   
    low portc.0      
    If porta.3 = 1 then led   ' when switch is pressed it goes to label "led" right?
    goto start
    
    led:
    high portc.0    'here should the led light up?
    pause 100
    goto start
    end
    It happens NOTHING with this code.
    If i change the value to "If porta.3 = 0 then led" the led always lights up except when switch is pressed down.
    Any suggestions?
    How is everything connected?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2009
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    It is the Low Pin Count Demo Board from PICkit2.
    You can see schematic diagram in attached file!
    Attached Images Attached Images  

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Do you have JP5 connected?
    Without JP5 connected you will get strange results.
    With JP5 connected A3 will always be high, then when the button is pressed A3 will go low.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default

    I don't know what MCU chip you are using but if it has and A/D capability PORT A starts up in Analog mode. If this is the case you can fix the problem by:

    1. Avoiding PORTA or

    2. Looking up the A/D info in the MCU spec. This is often in the ADCON1 register and PORTA made digital by putting something like

    ADCON1 = %00001111

    near the beginning of your code. Good luck

    Regards Bill Legge

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bill Legge View Post
    I don't know what MCU chip you are using but if it has and A/D capability PORT A starts up in Analog mode. If this is the case you can fix the problem by:
    The MCU should be a 16F690 ans A3 doubles as MCLR.

    BTW.
    How are the configs set ?
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30
  5. Greetings from Newbie and a question
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th July 2006, 15:52

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