کد:
$regfile = "m128def.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Down , Compare C Pwm = Clear Down , Prescale = 1
Config Graphlcd = 128 * 64 , Dataport = Porta , Controlport = Portc , Ce = 0 , Cd = 1 , Wr = 2 , Rd = 3 , Reset = 4 , Fs = 5 , Mode = 8
Cursor Off
Config Portb.5 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Dim A As Byte
A = 1
Dim V1 As Word
Dim V2 As Word
Dim V3 As Word
Dim Va As Single
Dim Vb As Single
Dim Vc As Single
Dim Va1 As String * 7
Dim Vb1 As String * 7
Dim Vc1 As String * 7
Pwm1a = 100
Pwm1b = 100
Pwm1c = 100
Goto Sh1
V:
Cls
Do
'For A = 1 To 2
V1 = Getadc(0)
Va = V1 / 204.6
Va1 = Fusing(va , "#.##")
V2 = Getadc(1)
Vb = V2 / 204.6
Vb1 = Fusing(vb , "#.##")
V3 = Getadc(2)
Vc = V3 / 204.6
Vc1 = Fusing(vc , "#.##")
'Cls
'Cls Text
'Cls Graph
Locate 1 , 1
Lcd "ADC(0):" : Lcd Va1 : Lcd " v"
Locate 2 , 1
Lcd "ADC(1):" : Lcd Vb1 : Lcd " v"
Locate 3 , 1
Lcd "ADC(2):" : Lcd Vc1 : Lcd " v"
'Wait 100
'Next A
Loop
Sh1:
Cls
Cls Text
Cls Graph
Showpic 0 , 0 , Pic1 , 1
Wait 1
Sh2:
Cls
Cls Text
Cls Graph
Showpic 1 , 0 , Pic2 , 1
Wait 1
Goto V
End
Pic1:
$bgf "uni.bgf"
Pic2:
$bgf "uni2.bgf"
Goto V