Don't you see? You display a decimal number but the number is in fact 245 and not 24.5!
So, maybe you can use word variables and multiply them by 10 so you can compare 245 to 160 and 300.
My first suggestion was to make sure that bit 0 of ADCON0 was set. It needs some time and if you go fast to start ADC, the module might not work as expected. I am sorry that I made the mistake of bit 0 to 2. Please include it as this:
Code:
ADCON0=%10000101
while !adcon0.0:wend
I would not set bit 2 at this stage but anyway.
Ioannis
Bookmarks