get a sensor digital input to work on a pickit 2 16f690 lpc


Results 1 to 16 of 16

Threaded View

  1. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: get a sensor digital input to work on a pickit 2 16f690 lpc

    Quote Originally Posted by Jasonstew View Post
    Also with the digital sensor program, the light turns on when the state changes, but won't shut off unless i push the button on the lpc. Why? Thanks again. This is the code:
    In your code, your TRISC line is not right, you must set some inputs there.... as it is right now, there's only OUTPUT. Change it to
    Code:
          ' 
          '  76543210
    TRISC = %10000000
          ' -1-------- PORTB.7 = INPUT
          ' --0000000- PORTB<6:0> = OUTPUT
    And then your main loop may looks like...
    Code:
    Start:
            IF PORTC.7 = 1 THEN
                    PORTC.0 = 1
                    ELSE
                            PORTC.0 = 0
                    ENDIF
            PAUSE 1000
            GOTO Start
    OR.. WAY easier
    Code:
    Start:
            PORTC.0 = PORTC.7
            PAUSE 1000
            GOTO Start
    In your code, you enable the Pull up on PORTA, there's no internal pull-up available for PORTC, so I hope you have one
    Last edited by mister_e; - 26th June 2011 at 09:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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