Device = 18F1320
Clock = 4
Config OSC = INTIO2, WDT = OFF, LVP = OFF
Include "USART.bas"
Include "ADC.bas"
Include "convert.bas"
Dim ADVal As Word
// Read the AD port and scale for 0.00 - 5.00 volts...
Function ADInAsVolt() As Word
result = (ADC.Read(1) + 1) * 500 / 1024
End Function
// Start Of Program...
OSCCON = $62 ' 4MHz internal clock
SetBaudrate (br9600)
// main program loop...
While true
ADVal = ADInAsVolt
USART.Write("DC Volts = ", DecToStr(ADVal / 100), ".", DecToStr(ADVal, 2), " ",13,10)
DelayMS(500)
Wend