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:
How about this...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
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.Code:Start: PortC.0=PortC.7 Pause 1000 goto Start
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.





Bookmarks