Hi Lauren,

Do you still require assistance with your project ?

'mister e' is putting you on the right track. Try and use 'hardware' peripheral's
as much as you can to alleviate software latency issues. PBpro commands are great to get code off the ground quickly, but due to their inherent power, they generate quite a large amount of code to operate. Take a look at the 'asm' file, after compilation, and you will see what I mean.

meLAB's are a brilliant source for Microchip development stuff as you will see during your learning curve (none of us ever stop learning !).

Judging by the ADCON register configuration, it appears that you are using the internal A\D reference tied to the +5V logic rail and are most likely using the 'single turn' pot on the X1 board for your 0 - 5V signal. I imagine that there are two problems this project is suffereing from -

Circuit wise, there will be a lot of noise on the +5V rail and 'single turn' pot's are notoriously difficult to set with any accuracy.

Software wise, your code is looking for a 'literal' value (with the use of = and <>) in the 'IF_THEN' statements.

Bearing this in mind, the 'result register' only has to deviate by one least significant bit from the 'constant value' and the whole process will produce unexpected\unwanted results.

If you would like some sample code, please, DO NOT hesitate to ask.

Regards Mike B. Australia.