سلام دوستان
من این وسیله رو ساختم با Uart
ولی بعد از 1-2 ساعت ارتباط با میکرو قطع میشه !
اینم کد میکرو :


$regfile "m8def.dat"
$crystal = 8000000
$baud = 9600
Config Serialin = Normal
Config Serialout = Normal

'------------------------------------------------------------------------------------
Config Portb.0 = Output ' Power
Config Portb.1 = Output ' Relay (1)
Config Portb.2 = Output ' Relay (2)
Config Portb.3 = Output ' Relay (3)
Config Portb.4 = Output ' Relay (4)


Dim A As Byte
Dim R As Bit
R = 0

Set Portb.0


Declare Sub R1(byval A As Byte)
Declare Sub R2(byval A As Byte)
Declare Sub R3(byval A As Byte)
Declare Sub R4(byval A As Byte)
Declare Sub Status()



Do
A = 0
A = Inkey()

If Chr(a) = "R" Then
R = 1
Waitms 100
Print "Y"
Elseif Chr(a) = "S" Then
'-----------------------------------------------------------------------------
Elseif Chr(a) = "1" Or Chr(a) = "5" Then
Call R1(a)
Elseif Chr(a) = "2" Or Chr(a) = "6" Then
Call R2(a)
Elseif Chr(a) = "3" Or Chr(a) = "7" Then
Call R3(a)
Elseif Chr(a) = "4" Or Chr(a) = "8" Then
Call R4(a)
'-----------------------------------------------------------------------------
End If


Loop




Sub R1(byval _a As Byte)
If R = 1 Then
If Chr(a) = "1" Then
Set Portb.1
Elseif Chr(a) = "5" Then
Reset Portb.1
End If

Waitms 50
Print "D"
R = 0
End If
End Sub R1(byval A As Byte)

Sub R2(byval _a As Byte)
If R = 1 Then
If Chr(a) = "2" Then
Set Portb.2
Elseif Chr(a) = "6" Then
Reset Portb.2
End If

Waitms 50
Print "D"
R = 0
End If
End Sub R2(byval A As Byte)

Sub R3(byval _a As Byte)
If R = 1 Then
If Chr(a) = "3" Then
Set Portb.3
Elseif Chr(a) = "7" Then
Reset Portb.3
End If

Waitms 50
Print "D"
R = 0
End If
End Sub R3(byval A As Byte)

Sub R4(byval _a As Byte)
If R = 1 Then
If Chr(a) = "4" Then
Set Portb.4
Elseif Chr(a) = "8" Then
Reset Portb.4
End If

Waitms 50
Print "D"
R = 0
End If
End Sub R4(byval A As Byte)

Sub Status()
If R = 1 Then

If Portb.1 = 1 Then
Print "1"
Else
Print "5"
End If
Waitms 50

If Portb.2 = 1 Then
Print "2"
Else
Print "6"
End If
Waitms 50

If Portb.3 = 1 Then
Print "3"
Else
Print "7"
End If
Waitms 50

If Portb.4 = 1 Then
Print "4"
Else
Print "8"
End If

Waitms 50
Print "D"
R = 0
End If
End Sub Status()