با عرض پوزش برای استفاده در محیط نرم افزار پروتئوس اتصال گراند یکی از پین های ال سی دی )RW( رو حذف کنید
(این نوشته ی روی عکس هارو خود سایت اضافه میکنه دیگه حالشو ندارم غیر فعالش کنم بعد دباره فعال شرمنده)
کد:
$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 100
$swstack = 100
$framesize = 100
Config Portb = Input
Config Portd = Input
Config Portc = Input
Portb = 255
Portd = 255
Portc = 255
Led Alias Portd.7
Set Portd.6
Dim Ti As Byte
Set Portb.1
Set Portb.2
Set Portb.3
Set Portb.4
Set Portb.5
Config Portd.4 = Output
Config Portd.5 = Output
Config Portd.7 = Output
Config Portb.0 = Output
Set Portd.4
Config Portb.0 = Input
Portb.0 = 0
Disable Interrupts : Set Portd.4
On Ovf1 Sectic
Config Timer1 = Timer , Prescale = 256
Enable Timer1
Enable Ovf1
Start Timer1
Timer1 = 34286
On Urxc Rs
Enable Urxc
$baud = 9600
Reset Portd.7
Light Alias Portb.0
Config Adc = Single , Prescaler = 128 , Reference = Avcc
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0 , Wr = Portd.5
Config Lcd = 16 * 2
Dim Lt As Byte
Deflcdchar [0] , 31 , 32 , 32 , 32 , 32 , 32 , 32 , 31 ' replace [x] with number (0-7)
Deflcdchar [1] , 31 , 16 , 16 , 16 , 16 , 16 , 16 , 31 ' replace [x] with number (0-7)
Deflcdchar [2] , 31 , 24 , 24 , 24 , 24 , 24 , 24 , 31 ' replace [x] with number (0-7)
Deflcdchar [3] , 31 , 28 , 28 , 28 , 28 , 28 , 28 , 31 ' replace [x] with number (0-7)
Deflcdchar [4] , 31 , 30 , 30 , 30 , 30 , 30 , 30 , 31 ' replace [x] with number (0-7)
Deflcdchar [5] , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 ' replace [x] with number (0-7)
Dim L(2) As String * 16
Dim D As Byte
Dim C As String * 1
Dim A As Word
Dim B As Single
Dim E As Bit
Dim Ln As Bit
Display On
Cls
Cursor Off
Lt = 0
Light = 1
Start Adc
Led = 1
Lcd "Hi!"
Lowerline
A = Getadc(6)
A = A * 5
B = A / 1023
C = Fusing(b , "#.#")
Lcd "Temp Is: " ; C ; "'C"
Wait 1
Lt = 0
Cls
A = Getadc(7)
A = A * 5
B = A / 1023
C = Fusing(b , "#.#")
Lcd "LCD Cont: " ; C ; "V"
Lowerline
A = Getadc(14)
A = A * 5
B = A / 1023
C = Fusing(b , "#.#")
Lcd "Int Ref is: " ; C ; "V"
Wait 1
Lt = 0
Cls
Reset Portd.4
Enable Urxc
Enable Interrupts : Reset Portd.4
Start Timer1
Config Watchdog = 2048
Start Watchdog
Do
Reset Portd.4
If E = 1 Then
Disable Interrupts : Set Portd.4
Set Portd.4
Cls
Lcd L(1)
Lowerline
Lcd L(2)
Lt = 0
Light = 1
E = 0
A = Ln + 1
L(a) = ""
Lt = 0
Light = 1
Enable Interrupts : Reset Portd.4
End If
If Len(l(1)) = 0 Then
If Len(l(2)) = 0 Then
Ln = 0
Light = 0
End If
End If
If L(1) = "disoff" Or L(2) = "disoff" Then
Display Off
L(1) = ""
L(2) = ""
E = 0
Ln = 0
End If
If L(1) = "dison" Or L(2) = "dison" Then
L(1) = ""
L(2) = ""
E = 0
Ln = 0
Display On
End If
If Pind.6 = 0 Then
Set Portd.4
Disable Interrupts : Set Portd.4
Led = 1
While Pind.6 = 0
Set Portd.4
Cls
Wait 1
Lcd " BehzadMokhtari "
Lowerline
Lcd " @live.com "
Wait 2
Light = 1
Wend
Cls
Light = 0
L(1) = ""
L(2) = ""
E = 0
Ln = 0
Enable Interrupts : Reset Portd.4
Reset Portd.4
End If
Idle
Loop
End
Sectic:
Toggle Led
Timer1 = 34286
If Lt = 6 Then
Light = 0
Lt = 0
Else
Incr Lt
End If
Reset Watchdog
Return
Rs:
D = Udr
Disable Interrupts : Set Portd.4
Light = 1
C = Chr(d)
If D < 6 Then
Lcd Chr(d)
C = ""
End If
If C = "$" Then
E = 1
Light = 1
Toggle Ln
Else
A = Ln + 1
L(a) = L(a) + C
End If
If Len(l(a)) = 16 Then
Toggle Ln
E = 1
Light = 1
End If
If E = 1 Then
Enable Interrupts
Set Portd.4
Else
Enable Interrupts : Reset Portd.4
End If
Return
برنامه همراه با I2C یکم وقت میخواد که فعلا موجود نیست اگه هم بهش نیاز دارید بهتره این برد رو نسازید چون به احتمال زیاد باید تغییر پیدا کنه(خودم که کارم راه افتاده دیگه فکر ایناش نبودم!)