' Quantisized ADIN Results. And display on a serial LCD Device 16F877 Declare XTAL 20 ' Set Xtal Frequency Declare RSOUT_PIN PORTB.0 Declare ADIN_TAD FRC ' Set clock source (x/FOSC or FRC) Declare ADIN_STIME 150 ' Set sampling time (in uS) Dim AD_Raw as Word ' 10-bit result of A/D conversion Dim AD_Result as Word ' Quantasized ADC result Dim Average as Word ' Build up the average result Dim Samples as Byte Rsout Cls ' Clear the serial LCD ADCON1 = %10000000 ' Right justified result in ADRESL and ADRESH Again: Average = 0 ' Clear the Average variable before use For Samples = 0 to 9 ' We will take 10 samples of the ADC AD_Raw = ADIN 0 ' Place the conversion of channel 0 Average = Average + AD_Raw ' Build up the Average result Next ' Close the loop after 10 revolutions AD_Result = (Average/10) */ 1250' Quantasize the result Rsout at 1,1,@AD_Result / 1000,".",Dec3 AD_Result // 1000," Volts " Goto Again ' Do it forever