$regfile = "M8DEF.DAT"
$crystal = 8000000
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db7 = Portd.7 , Db6 = Portd.6 , Db5 = Portd.5 , Db4 = Portd.4 , E = Portd.3 , Rs = Portd.2
Dim C As Long
Dim D As Long
Const X = 98
'D =((C*5000000)/256-4000000)/(16*X)
Const Z1 = 5000000 / 256
Const Z2 = 16 * X
Start Adc
Do
 C = Getadc(0)
 D = C * Z1
 D = D - 4000000
 D = D / Z2
 Home : Lcd "Depth: " ; D ; "cm   "
' Wait 1
Loop
End