KARIM102
08-24-2010, 08:22 PM
Hi everyone,
why this code is not working???
THRID:
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud,["A",A,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["B",B,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["C",C,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["D",B,13,10] ' send word
RESURT:
DO
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("A")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("B")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("C")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("D")] ' recived word
IF A =1 THEN ' when the word "A" recived
HIGH 15 ' relay "A" energized
LOW 14 ' other relays de-energized
LOW 13
LOW 12
GOTO START
ELSEIF B = 1 THEN ' relay "B" energized
HIGH 14 ' other relays de-energized
LOW 15
LOW 13
LOW 12
GOTO START
ELSEIF C = 1 THEN ' relay "C" energized
HIGH 13 ' other relays de-energized
LOW 14
LOW 15
LOW 12
GOTO START
ELSEIF D = 1 THEN ' relay "D" energized
HIGH 12 ' other relays de-energized
LOW 14
LOW 13
LOW 15
GOTO START
ELSE ' when there aren't any signls
HIGH 12 ' All relays de-energized
LOW 14
LOW 13
LOW 15
ENDIF
LOOP
KARIM102
08-25-2010, 07:13 PM
OK MATE this is my code it's for sms reciving and controller
' {$STAMP BS2e}
' {$PBASIC 2.5}
'----------------------[variables]----------------------------------------------
A VAR Word
B VAR Word
C VAR Word
D VAR Word
E VAR Word
F VAR Word
'---------------------[Initializations]-----------------------------------------
HELP:
LOW 15
LOW 14
LOW 13
LOW 12
'================================================= ================================================== ====
'----------------------main routine --------------------------------------------------------------------
'================================================= ================================================== ====
frist:
A = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN, [WAIT("OK")]
SECOND:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND,[WAIT("OK") ]
THRID:
PAUSE 500
SEROUT 0 , 84,["A",A,13,10] ' send word.
DO
SERIN 1 , 84,3000,THRID ,[WAIT("A")] ' recived word
IF A =1 THEN
HIGH 15
LOW 14
LOW 13
LOW 12
GOTO kok
ENDIF
LOOP
kok:
B = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN1:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN1, [WAIT("OK")]
SECOND1:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND1,[WAIT("OK") ]
THRID1:
PAUSE 500
SEROUT 0, 84,["B",B,13,10]
DO
SERIN 1 , 84,3000,THRID1, [WAIT("B")] ' recived word
IF B =1 THEN
HIGH 14
LOW 15
LOW 13
LOW 12
GOTO frist1
ENDIF
LOOP
frist1:
C = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN2:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN1, [WAIT("OK")]
SECOND2:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND2,[WAIT("OK") ]
THRID2:
PAUSE 500
SEROUT 0, 84,["C",C,13,10]
DO
SERIN 1 , 84,3000,THRID2, [WAIT("C")] ' recived word
IF C =1 THEN
HIGH 13
LOW 15
LOW 14
LOW 12
GOTO frist2
ENDIF
LOOP
frist2:
D = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN3:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN3, [WAIT("OK")]
SECOND3:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND3,[WAIT("OK") ]
THRID3:
PAUSE 500
SEROUT 0, 84,["D",D,13,10]
DO
SERIN 1 , 84,3000,THRID3, [WAIT("D")] ' recived word
IF D =1 THEN
HIGH 12
LOW 15
LOW 14
LOW 13
GOTO frist3
ENDIF
LOOP
frist3:
E = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN4:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN4, [WAIT("OK")]
SECOND4:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND4,[WAIT("OK") ]
THRID4:
PAUSE 500
SEROUT 0, 84,["ALL",E,13,10]
DO
SERIN 1 , 84,3000,THRID4, [WAIT("ALL")] ' recived word
IF E =1 THEN
HIGH 12
HIGH 15
HIGH 14
HIGH 13
GOTO frist4
ENDIF
LOOP
frist4 :
F = 1
PAUSE 500
SEROUT 0 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 1, 84 , [WAIT("OK")]
MAIN5:
PAUSE 500
SEROUT 0 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 1 , 84,3000,MAIN5, [WAIT("OK")]
SECOND5:
PAUSE 500
SEROUT 0,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 1 , 84,3000,SECOND5,[WAIT("OK") ]
THRID5:
PAUSE 500
SEROUT 0, 84,["CLOSE",F,13,10]
DO
SERIN 1 , 84,3000,THRID5, [WAIT("CLOSE")] ' recived word
IF D =1 THEN
GOTO HELP
ENDIF
LOOP
'-------------------------------------[END]----------------------------------------------
KARIM102
08-25-2010, 08:30 PM
i see,, i have GE864 GSM, this coding which i made it, it read the sms which you send it and make the action like this statment.
SEROUT 0 , 84,["A",A,13,10] '
which will send throw the TX temail for GSM from Basic stamp and the wait for any phone which send A as sms message
SERIN 1 , 84,3000,THRID ,[WAIT("A")] '
when you send "A" for ur phone to this GSM it will RX it and make action to pin from stamp
IF A =1 THEN
HIGH 15
LOW 14
LOW 13
LOW 12
GOTO kok
and then go to the next state.....
the problem is i don't wanna the order which i should go through all these sms to reach for explain "D" SMS,,,, i wanna any of these sms message will be action without make them in order.....
i wish u get what i am asking....
Mike Green
08-25-2010, 09:18 PM
You must show me what you want the SEROUT statement to send. For example, if A has the value 33, then the SEROUT statement
SEROUT 0,84,["A",A,13,10]
is the same as
SEROUT 0,84,["A",33,13,10]
Since 33 is the same as the character "!", the SEROUT is the same as
SEROUT 0,84,["A","!",13,10]
KARIM102
08-26-2010, 02:15 AM
i put each variable = 1, so when it recived the messges it will make A = 33, but how could i use two serout or more and in the same time how could i use two serin or more see the coding!!!
' {$STAMP BS2e}
' {$PBASIC 2.5}
'----------------------[variables]----------------------------------------------
A VAR Word ' INPUT FOR THE MIRCONTROLLER
B VAR Word ' INPUT FOR THE MIRCONTROLLER
C VAR Word ' INPUT FOR THE MIRCONTROLLER
D VAR Word ' INPUT FOR THE MIRCONTROLLER
' -----------------[ I/O Definitions ]------------------------------------------
GPRS_RX PIN 0
GPRS_TX PIN 1
' --------------------[ Constants ]---------------------------------------------
GPRS_Baud CON 84
'---------------------[Initializations]-----------------------------------------
LOW 15
LOW 14
LOW 13
LOW 12
'================================================= ================================================== ====
'----------------------main routine --------------------------------------------------------------------
'================================================= ================================================== ====
START:
A = 1
B = 1 ' MAKR ALL VARABLE ONE
C = 1
D = 1
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN GPRS_RX, GPRS_Baud,3000,START [WAIT("OK")]
MAIN:
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud, ["AT+CMGF=1", 13,10] ' Text mode
SERIN GPRS_RX, GPRS_Baud,3000,MAIN, [WAIT("OK")]
SECOND:
SEROUT GPRS_TX, GPRS_Baud, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN GPRS_RX, GPRS_Baud,3000,SECOND[WAIT("OK") ]
THRID:
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud,["A",A,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["B",B,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["C",C,13,10] ' send word
SEROUT GPRS_TX, GPRS_Baud,["D",B,13,10] ' send word
RESURT:
DO
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("A")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("B")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("C")] ' recived word
SERIN GPRS_RX, GPRS_Baud,3000,THRID, [WAIT("D")] ' recived word
IF A =1 THEN ' when the word "A" recived
HIGH 15 ' relay "A" energized
LOW 14 ' other relays de-energized
LOW 13
LOW 12
GOTO START
ELSEIF B = 1 THEN ' relay "B" energized
HIGH 14 ' other relays de-energized
LOW 15
LOW 13
LOW 12
GOTO START
ELSEIF C = 1 THEN ' relay "C" energized
HIGH 13 ' other relays de-energized
LOW 14
LOW 15
LOW 12
GOTO START
ELSEIF D = 1 THEN ' relay "D" energized
HIGH 12 ' other relays de-energized
LOW 14
LOW 13
LOW 15
GOTO START
ELSE ' when there aren't any signls
HIGH 12 ' All relays de-energized
LOW 14
LOW 13
LOW 15
ENDIF
LOOP
i tried this but it doesn't work!!!!
is cz the serin just may use once!!!! or there is a way out!!!
thx