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


Results 1 to 16 of 16

Threaded View

  1. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

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

    Well JasonStew,
    Digital is simple, if you have the 5 v it is a one and if not it is a zero, so set one of the ports to input, just for hoots I will say PortB.7 like so TRISB = %10000000 and now portb.7 is an input. Now really simple Psuedocode If Portb.7 = 1 then portb.6 = 1 and viola if portb.7 is switched on then it switches the output on portb.6 to on status. You see I set the other 3 usable ports on PortB as outputs in the tris statement. I think it causes less confusion if you get in the habit of using all 8 bits in your port and register declarations even when the port has "unimplemented" bits like the 4 lower bits(ports) in portb of the 16f690. When you setup the ports and tris registers, it seems counter intuitive but set the port register first then set up the tris register. That way any outputs are set to the desired state before they become outputs (THANKS BRUCE ).
    Last edited by Archangel; - 24th June 2011 at 17:04.

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