ADC accuracy pic16f887
You need to actually read the datasheet, particularly the chapter on the A/D.  Two obvious problems from a quick look at the code are that you aren't giving the A/D time to stabalize after turning it on, and you aren't giving it any acquisition time.

Try leaving the A/D on all the time.  That gets around both problems, assuming you leave enough time after one conversion before starting the next.  It seems you have some delays in there, so this condition is met.

Again, how to use the A/D properly is well described in the datasheet.  Read it.

Once you get it basically working, you can do some low pass filtering on the readings to reduce the remaining one or two counts of noise about the average.

I usually run the A/D faster than I need from interrupt code.  This also low pass filters the sequence of readings, then leaves the filtered value in a global variable that the foreground code can grab whenever it wants to.  That way the A/D readings and usage of the values are decoupled, allowing each piece of code to do the one thing it does well, and be reasonably independent of other parts of the system.  Everything intertwined, as in your code, will get you into trouble when you try to grow the system beyond the simplest of demos.