You are on page 1of 10

'------------------------------------------------------------------------------'Program komunikasi hp dengan mikro created by fahmizal

'------------------------------------------------------------------------------$regfile = "m8535.dat"
$crystal = 12000000
$baud = 19200

'siemens c35,m35,c45

Const Cmaxchar = 160


'------------------------------------------------------------------------------'Configurasi pin
'------------------------------------------------------------------------------Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 =
Porta.7 , E = Porta.1 , Rs = Porta.0
Config Lcd = 16 * 2

Config Portc = Output

Lampu1 Alias Portc.0


Lampu2 Alias Portc.1

'------------------------------------------------------------------------------'Declarasi subrutin
'-------------------------------------------------------------------------------

Declare Sub 1padam()


Declare Sub 2padam()
Declare Sub 1nyala()
Declare Sub 2nyala()

'------------------------------------------------------------------------------'Declarasi variabel
'------------------------------------------------------------------------------Dim Bc As Byte
Dim Buf1 As String * Cmaxchar
Dim S As String * 23
Dim Sambung As String * 2
Dim Type As String * 3
Dim Pesan As String * 2
Dim Pesane As String * 2
Dim Hp As String * 7
Dim A As Integer
Dim Smse As String * 14

'------------------------------------------------------------------------------'Salam pembuka
'-------------------------------------------------------------------------------

Cls
Lcd " Diploma TE "
Waitms 500
Lowerline
Lcd "
Wait 1

U_G_M

"

Cls
Lcd "created by

"

Waitms 500
Lowerline
Lcd "Fahmizal

"

Wait 1

Cls
Lcd "KendaliJarakJauh"
Waitms 500
Lowerline
Lcd "

dengan hp "

Wait 1

'--------------------------------------'hidupkan komunikasi serial hp


'---------------------------------------

On Urxc Rec_isr

'------------------------------------------------------------------------------'Rutin program utama


'-------------------------------------------------------------------------------

Cls
Do

Print "AT"
Enable Urxc
Enable Interrupts
Cls
Lcd "CHECK CONNECTION"
Lowerline
Lcd "CHECK UOUR CABLE"
Wait 3
Cls
Lcd "== WAITTING =="
Lowerline
Lcd "=============="
Wait 3
S = Right(buf1 , 4)
Sambung = Left(s , 2)
Disable Urxc
Disable Interrupts
Buf1 = ""
Loop Until Sambung = "OK"

Cls
Lcd " CONNECTION "
Lowerline
Lcd "CONGGRATULATION"
Wait 3

Print "AT+CGMI"
Enable Urxc
Enable Interrupts
Cls
Lcd "What is your HP?"
Lowerline
Lcd "================"
Wait 3
S = Mid(buf1 , 11)
Hp = Left(s , 7)
Cls
Lcd Hp
Disable Urxc
Disable Interrupts
Buf1 = ""
Print "AT+CGMM"
Enable Urxc
Enable Interrupts
Lowerline
Wait 3
S = Mid(buf1 , 11)
Type = Left(s , 3)
Lcd Type
Wait 3
Cls
Disable Urxc

Disable Interrupts
Buf1 = ""

Do
Print "AT+CMGL=0"
Enable Urxc
Enable Interrupts
Cls
Lcd "== ADA PESAN =="
Lowerline
Lcd "==============="
Wait 3
S = Right(buf1 , 22)
Type = Mid(s , 2 , 2)
Smse = Right(buf1 , 13)
Pesane = Mid(smse , 2 , 2)

Cls
If Pesan = "19" Then Call 1nyala()
If Pesan = "11" Then Call 1padam()
If Pesan = "29" Then Call 2nyala()
If Pesan = "21" Then Call 2padam()
If Pesane = "MG" Then
Lcd "Tidak ada pesan"
Wait 3
Else

Lcd Pesane
Wait 3
End If

Disable Urxc
Disable Interrupts
Buf1 = ""
Loop
End

'------------------------------------------------------------------------------'Interupsi Serial
'-------------------------------------------------------------------------------

Rec_isr:
If Bc < Cmaxchar Then
Buf1 = Buf1 + Chr(udr)
End If
Return

'------------------------------------------------------------------------------'program subrutin
'------------------------------------------------------------------------------Sub 1nyala()
A=A+1
Cls

Lcd "================"
Lowerline
Lcd "LAMPU 1 NYALA"
Wait 1
Do
A=A+1
Reset Lampu1
Print "AT+CMGD=1"
Loop Until A = 8
End Sub

Sub 1padam()
A=A+1
Cls
Lcd "================"
Lowerline
Lcd "LAMPU 1 PADAM"
Wait 1
Do
A=A+1
Set Lampu1
Print "AT+CMGD=1"
Loop Until A = 8
End Sub

Sub 2nyala()
A=A+1
Cls
Lcd "==============="
Lowerline
Lcd "LAMPU 2 NYALA"
Wait 1
Do
A=A+1
Reset Lampu2
Print "AT+CMGD=1"
Loop Until A = 8
End Sub

Sub 2padam()
A=A+1
Cls
Lcd "==============="
Lowerline
Lcd "LAMPU 2 PADAM"
Wait 1
Do
A=A+1
Set Lampu2
Print "AT+CMGD=1"
Loop Until A = 8

End Sub

You might also like