?? subadc中斷lcd顯示.bas
字號:
'**************************************************************************
' 入門例子]ADC中斷LCD顯示在PROTEUS6.9sp5仿真中通過
'名 稱 : 入門例子]ADC中斷LCD顯示.bas
'目 的 : ADC中斷LCD顯示在PROTEUS6.9sp5仿真中通過
'目 標 芯 片 : Mega16
'試 驗 環 境 : mega16_PROTEUS6.9sp5仿真
'編 譯 環 境 : BASCOM-AVR 1.11.8.1
'********************************************************************************
$regfile = "m16def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 9600 ' use baud rate
' default use 40 for the frame space
Config Adc = Single , Prescaler = Auto 'Prescaler = Auto Internal
Dim W1 As Long , Channe1 As Byte , V1 As Single
Enable Interrupts
' Enable Adc
' On Adc Adc_isr
Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.4 , Rs = Portb.5 '定義單片機與LCD的接口,請書寫在同一行
'定義液晶的型號
Declare Sub Adctest(w1 As Long , Channe1 As Byte , V1 As Single )
Cls
Cursor Off
Channe1 = 0
Do
Start Adc
Call Adctest(w1 , Channe1 , V1)
Loop
End
Sub Adctest(w1 As Long , Channe1 As Byte , V1 As Single)
Dim V2 As String * 10
V2 = Str(v1)
W1 = Getadc(channe1)
W1 = W1 * 500
W1 = W1 / 1023 '將10位A/D轉換器的值轉化為十進制
V2 = Str(w1) ' 數字轉換為字符串
V2 = Format(v2 , "0.00")
Wait 100 '確定小數點
Locate 1 , 1 : Lcd "Ch " ; Channe1 ; " val " ; V2 ; "V" '打印模擬值
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -