کد:
$regfile = "M8DEF.DAT"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db7 = Pinb.5 , Db6 = Pinb.4 , Db5 = Pinb.3 , Db4 = Pinb.2 , E = Pinb.1 , Rs = Pinb.0
Cursor Off
'**********************************************************
Config Portd = Input
Pind.0 = 1
Pind.1 = 1
Pind.2 = 1
Pind.3 = 1
Key_menu Alias Pind.0
Key_incr Alias Pind.1
Key_decr Alias Pind.2
Key_door Alias Pind.3
'**********************************************************
Dim V As Word
Dim Input_mv As Single
Dim Input_v As Single
Dim Temp As Single
Dim A As Word
Dim B As Single
'****************
Dim C As Word
Dim D As Word
Dim E As Word
Dim F As Word
Dim Door As Word
Dim Sh As Integer
'**********************************************************
Enable Interrupts
Config Date = Ymd , Separator = /
Config Clock = Soft , Gosub = Sectic
_sec = 00 : _min = 00 : _hour = 12 : _day = 10 : If _day > 31 Then _day = 01 : _month = 02 : If _month > 12 Then _month = 01 : _year = 91
'**********************************************************
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Single = Scientific , Digits = 1
'**********************************************************
W:
Cls
Deflcdchar 1 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32
Locate 1 , 1 : Lcd Date$ : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B ; "V"
'**********************************************
Do
Debounce Key_menu , 0 , Incr_day : Waitms 100
Debounce Key_door , 0 , _door : Waitms 200
Gosub Read_adc
Loop
'******************** Tanzim Tarikh
Incr_day:
For C = 1 To 150
Locate 1 , 1 : Lcd Date$ : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Debounce Key_menu , 0 , Incr_month : Waitms 100
If Key_incr = 0 Then : Incr _day : Waitms 400 : End If
If Key_decr = 0 Then : Decr _day : Waitms 400 : End If
Waitms 70
Locate 1 , 1 : Lcd Date$ : Locate 1 , 7 : Lcd " " : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Incr C
Debounce Key_menu , 0 , Incr_month : Waitms 100
If Key_incr = 0 Then : Incr _day : Waitms 400 : End If
If Key_decr = 0 Then : Decr _day : Waitms 400 : End If
Waitms 250
Next
Goto W
'**********************************************
Incr_month:
Cls
For D = 1 To 150
Locate 1 , 1 : Lcd Date$ : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Debounce Key_menu , 0 , Incr_year : Waitms 100
If Key_incr = 0 Then : Incr _month : Waitms 400 : End If
If Key_decr = 0 Then : Decr _month : Waitms 400 : End If
Waitms 70
Locate 1 , 1 : Lcd Date$ : Locate 1 , 4 : Lcd " " : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Incr D
Debounce Key_menu , 0 , Incr_year : Waitms 100
If Key_incr = 0 Then : Incr _month : Waitms 400 : End If
If Key_decr = 0 Then : Decr _month : Waitms 400 : End If
Waitms 250
Next
Goto W
'**********************************************
Incr_year:
Cls
For E = 1 To 150
Locate 1 , 1 : Lcd Date$ : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Debounce Key_menu , 0 , W : Waitms 100
If Key_incr = 0 Then : Incr _year : Waitms 400 : End If
If Key_decr = 0 Then : Decr _year : Waitms 400 : End If
Waitms 70
Locate 1 , 1 : Lcd Date$ : Locate 1 , 1 : Lcd " " : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Incr E
Debounce Key_menu , 0 , W : Waitms 100
If Key_incr = 0 Then : Incr _year : Waitms 400 : End If
If Key_decr = 0 Then : Decr _year : Waitms 400 : End If
Waitms 250
Next
Goto W
'**********************************************
Sectic:
If Key_door = 0 Then Return
Deflcdchar 1 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32
Locate 1 , 1 : Lcd Date$ : Locate 1 , 10 : Lcd " " ; Fusing(temp , "#.#") ; Chr(1) ; "C "
Locate 2 , 12 : Lcd B : Lcd "V"
Return
_door:
Cls
For Sh = 1 To 600
Locate 1 , 3 : Lcd "Open The Door"
If Key_door = 1 Then Goto W
Incr Sh
Next
Goto W
End
'**********************************************
Read_adc:
A = Getadc(0)
V = Getadc(1)
B = A : B = B / 51.15
Input_mv = V * 4.8828125
'Input_v = Input_mv / 1000
Temp = Input_mv / 10
Return
'**********************************************
بعدش دوستان اگر امكانش هست برام نكات موقع بست مدار رو بگيد ممنون ميشم (مثلا خازن صافي و... رو چطور و كجا بزارم)