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


Results 1 to 16 of 16

Threaded View

  1. #10
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

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

    Hey Jason... Looks like you are making progress. At least you are getting LED's to blink, instead of fighting with compilers.

    I have not tried your example program above, but you might try reversing the order of your "IF" statements.

    your code:
    Code:
    START:
    iF (PORTC.7= 1) THEN 
    PORTC.0 = 1
    ELSEIF (PORTC.7 != 1) THEN
    PORTC.0= 0
    ENDIF
    PAUSE 1000 
    PORTC.0=0
     
    GOTO Start

    With the IF statements reversed:
    Code:
    START:
    IF PORTC.7 = 0 THEN
    PORTC.0= 0
     
    ELSEIF PORTC.7= 1 THEN 
    PORTC.0 = 1
     
    ENDIF
    PAUSE 1000 
    PORTC.0=0
     
    GOTO Start
    How about this...
    Code:
    Start:
    PortC.0=PortC.7
    Pause 1000
    goto Start
    If you are useing the LPC demo board the push button is tied to MCLR which is resetting your PIC each time you push it, thus causing the LED to go off because you set portC =0 in your program.

    In order to do something similar with an analog sensor you would configure the pin as an analog input instead of digital... I will try and dig up a simple analog example and post it.

    One good tool that I find helpful would be to search on 16F690 and just look at various examples and try to see what others have done. Also look through various code examples in the "WIKI" section at the top of the forum. You might also look over on the MELabs web site, where they have several code examples for various PIC functions.

    PS. instead of using the Quote function to display code in your posts... Move over to the next icon "#" which is used to post code examples.
    Last edited by Heckler; - 26th June 2011 at 04:54.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

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