Hello everyone, I'm trying to read the value of a 50K Slider/potentiometer. I'm using ADCIN command on a Pic16F877A at 20Mhz. But the reading is not steady(jumping from one value to another). How can I have a smooth reading from 0 - 255? I read that it is better to use 10K potentiometer, but I have none for now...hope someone can help me out.
Code:
Code:
' Define ADCIN parameters
Define 20 OSC
Define ADC_BITS     8   ' Set number of bits in result
Define ADC_CLOCK    3   ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50  ' Set sampling time in uS


adval Var Byte          ' Create adval to store result


   TRISA = %11111111    ' Set PORTA to all input
   ADCON1 = %00000011  ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
mainloop:
   ADCIN 1, adval       ' Read channel 1 to adval
   Serout2 PORTC.6,84, ["Value: ", DEC adval, 13, 10] ' Display value to serial
   Pause 100            ' Wait .1 second
Goto mainloop        ' Do it forever


   End