سلام به همه
نیاز فوری
برنامه زیر رو نوشتم توی ارسال پیامک اصلا مشکلی نیست ولی توی دریافت مشکل دارم
یعنی وقتی به ماژول پیام ارسال می کنم مدار تغییری نمی کنه (توی گوشی فرستنده هم Delivered نمیزنه،یکی دو دفعه رسید ولی دیگه نرفت)
ولی وقتی زنگ میزنم مدار درست کار میکنه
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 64
$swstack = 64
$framesize = 64
'============================================ ===================================
'============================================ ===================================
Config Portc = Output
Config Portd.2 = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , _
Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Adc = Single , Prescaler = Auto
Config Timer0 = Timer , Prescale = 8
Enable Interrupts
Enable Timer0
On Timer0 Reza
Timer0 = 6
Dim D As Word , D1 As Word , G As Word , S As Byte , Z As Long , T As Byte
Dim B As Byte , K As Byte , F As Word , J As Byte : J = 4
Dim Sms As String * 250 : Sms = ""
'///////////////////////////////////////////////////////////////////////////////
Cursor Off
Locate 1 , 1
Lcd "Reza Nayerabadi"
Locate 2 , 1
Lcd "09304546778"
Wait 3
Cls
'///////////////////////////////////////////////////////////////////////////////
Enable Adc
Start Timer0
Print "AT"
Waitms 500
Print "AT+CMGD=1"
Waitms 500
Print "AT+CREG?"
Waitms 500
Print "ATE0"
Waitms 500
Print "AT+CNMI=1,1,0,0,0" 'new message indication off
Waitms 500
Print "AT+IPR=9600"
Waitms 500 'Third command TEXT MODE
Print "AT+CMGF=1"
Waitms 500
Do
Select Case S
Case 0 To 1:
T = 0
Locate 1 , 1
Lcd "Waiting...Sensor"
Locate 2 , 1
Lcd "is ganna ready"
Case Else:
'///////////////////////////////////////////////////////////////////////////////
D = Getadc(0)
D1 = D / 2
Select Case D1
Case Is <= 24:
Portc.0 = 0
Case Is >= 26:
Portc.0 = 1
End Select
Locate 1 , 1
Lcd "Dama : " ; D1 ; " "
'///////////////////////////////////////////////////////////////////////////////
G = Getadc(1)
Select Case G
Case 0 To 614:
T = 0
Portc.2 = 0
Locate 2 , 1
Lcd "Gas : Safe "
Case 615 To 1023:
While T = 0
Locate 2 , 1
Lcd "Gas : Danger"
T = 1
Portc.2 = 1
Print "AT"
Waitms 200
Print "AT+CMGF=1"
Waitms 200
Print "AT+CMGS=" ; Chr(34) ; "09304***778" ; Chr(34)
Waitms 200
Print "Danger" ; Chr(26)
Waitms 200
Wend
End Select
End Select
'///////////////////////////////////////////////////////////////////////////////
Print "AT"
Wait 1
Print "AT+CMGF=1"
If Pind.2 = 0 Then F = 0
If F < 2 Then
Print "AT+CMGR=1"
Sms = ""
B = Inkey()
Select Case B
Case 13:
If Sms <> "" Then Goto First
Case 10:
If Sms <> "" Then Goto First
Case Else
Sms = Sms + Chr(b)
Portc.1 = 1
End Select
First:
End If
Loop
End
'============================================ ===================================
'============================================ ===================================
Reza:
Stop Timer0
Z = Z + 1
If Z = 180000 Then
Z = 0
S = S + 1
Cls
If S > 200 Then S = 6
End If
Timer0 = 6
Start Timer0
Return
نیاز فوری
برنامه زیر رو نوشتم توی ارسال پیامک اصلا مشکلی نیست ولی توی دریافت مشکل دارم
یعنی وقتی به ماژول پیام ارسال می کنم مدار تغییری نمی کنه (توی گوشی فرستنده هم Delivered نمیزنه،یکی دو دفعه رسید ولی دیگه نرفت)
ولی وقتی زنگ میزنم مدار درست کار میکنه
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 9600
$hwstack = 64
$swstack = 64
$framesize = 64
'============================================ ===================================
'============================================ ===================================
Config Portc = Output
Config Portd.2 = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , _
Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Adc = Single , Prescaler = Auto
Config Timer0 = Timer , Prescale = 8
Enable Interrupts
Enable Timer0
On Timer0 Reza
Timer0 = 6
Dim D As Word , D1 As Word , G As Word , S As Byte , Z As Long , T As Byte
Dim B As Byte , K As Byte , F As Word , J As Byte : J = 4
Dim Sms As String * 250 : Sms = ""
'///////////////////////////////////////////////////////////////////////////////
Cursor Off
Locate 1 , 1
Lcd "Reza Nayerabadi"
Locate 2 , 1
Lcd "09304546778"
Wait 3
Cls
'///////////////////////////////////////////////////////////////////////////////
Enable Adc
Start Timer0
Print "AT"
Waitms 500
Print "AT+CMGD=1"
Waitms 500
Print "AT+CREG?"
Waitms 500
Print "ATE0"
Waitms 500
Print "AT+CNMI=1,1,0,0,0" 'new message indication off
Waitms 500
Print "AT+IPR=9600"
Waitms 500 'Third command TEXT MODE
Print "AT+CMGF=1"
Waitms 500
Do
Select Case S
Case 0 To 1:
T = 0
Locate 1 , 1
Lcd "Waiting...Sensor"
Locate 2 , 1
Lcd "is ganna ready"
Case Else:
'///////////////////////////////////////////////////////////////////////////////
D = Getadc(0)
D1 = D / 2
Select Case D1
Case Is <= 24:
Portc.0 = 0
Case Is >= 26:
Portc.0 = 1
End Select
Locate 1 , 1
Lcd "Dama : " ; D1 ; " "
'///////////////////////////////////////////////////////////////////////////////
G = Getadc(1)
Select Case G
Case 0 To 614:
T = 0
Portc.2 = 0
Locate 2 , 1
Lcd "Gas : Safe "
Case 615 To 1023:
While T = 0
Locate 2 , 1
Lcd "Gas : Danger"
T = 1
Portc.2 = 1
Print "AT"
Waitms 200
Print "AT+CMGF=1"
Waitms 200
Print "AT+CMGS=" ; Chr(34) ; "09304***778" ; Chr(34)
Waitms 200
Print "Danger" ; Chr(26)
Waitms 200
Wend
End Select
End Select
'///////////////////////////////////////////////////////////////////////////////
Print "AT"
Wait 1
Print "AT+CMGF=1"
If Pind.2 = 0 Then F = 0
If F < 2 Then
Print "AT+CMGR=1"
Sms = ""
B = Inkey()
Select Case B
Case 13:
If Sms <> "" Then Goto First
Case 10:
If Sms <> "" Then Goto First
Case Else
Sms = Sms + Chr(b)
Portc.1 = 1
End Select
First:
End If
Loop
End
'============================================ ===================================
'============================================ ===================================
Reza:
Stop Timer0
Z = Z + 1
If Z = 180000 Then
Z = 0
S = S + 1
Cls
If S > 200 Then S = 6
End If
Timer0 = 6
Start Timer0
Return
دیدگاه