$regfile = "M8def.dat" ' use the Mega8
$crystal = 8000000
Config Portc = Output
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc 'config ADC
Start Adc
Dim Volt1 As Single , V1 As Word ,
Cls
Cursor Off
Do
'wskaznik 0-15V
V1 = Getadc(2)
Volt1 = V1 * 0.0146
Locate 1 , 1
Lcd "U="
Lcd Fusing(volt1 , "#.##")
Lcd "v"
Locate 2 , 1
Lcd "TEST LCD :)";
Waitms 1000
Toggle Portc.5
Loop
Volt1 = V1 * 0.0146
Jak to policzyć,licząć ze wzoru Volt1=Uwej * 1024 /nap odniesienia
wychodzi 1024/5=204,8
mnożać x 3 bo taki mam dzielnik napięcia daje 614.
Licząć (5V nap ref / 1024 )*3 z dzielnika daje 0.0146
Co oczywiscie jest źle wyliczone bo mi LCD pokazuje wynik 0.07 naprzemiennie z 0.09 zamiast 11.55V;)