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

Originally Posted by
Jasonstew
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.
Bookmarks