MrDEB
Well-Known Member
trying to config a ADC input on port A.1 but this ADCON stuff??
Code:
Device = 18F452
Clock = 20
// some LCD options...
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTd.3
#option LCD_EN = PORTd.2
// uses LCD and AD libraries...
Include "LCD.bas"
Include "ADC.bas"
Include "convert.bas"
// read the AD port and scale for 0 - 5 volts...
Function ADInAsVolt() As Word
result = (ADC.Read(0) + 1) * 500 / 1024
End Function
// sampled AD value...
Dim ADVal As Word
// initialise and clear LCD...
ADCON1 = $07 // PORTd as digital (LCD) ????
TRISA.1 = 1 // configure AN0 as an input ?????
ADCON1.7 = 1 // set analogue input on PORTA.0 ??????
DelayMS (500)
LCD.Cls
// main program loop...
While true
ADVal = ADInAsVolt
LCD.MoveCursor (1,1)
LCD.Write("DC Volts = ", DecToStr(ADVal / 100), ".", DecToStr(ADVal, 2), " ")
DelayMS(250)
Wend