problem with output RA2 and RA3


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    i change with this:

    Code:
        CMCON = 7                       ' PortA = digital I/O    
    	ANSEL = %00000011               ' Will set RA0-RA1 as analog and all others as digital 
        TRISA = %00000011  
        ADCON0 = %11000001	            ' Configure and turn on A/D Module
        ADCON1 = %00000000 	            ' Left justified. Six Least Significant bits of ADRESL are read as ‘0’
    and work but i want only the positive result and not the negative of command: if (value - P2) >= 1
    23 - 25 = -2 (P2=25)
    27 - 25 = 2 (P2=25)
    the pin PORTA.2 turn on , and for -2 and for 2 , but i want only for 2.
    How to make this;

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Test if the first number is greater then the second number and then do the subtraction. If otherwise then do nothing.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mat janssen
    Test if the first number is greater then the second number and then do the subtraction. If otherwise then do nothing.
    Thank you.
    I use this code:

    Code:
        If value >= P2 then
            If (value - P2) >= 1 then
                PORTB.1=1
                else
                PORTB.1=0
                endif
            endif

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th August 2009, 23:57
  2. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  3. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  4. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  5. This should be simple?
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th September 2008, 21:20

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