serin
KARIM102
Posts: 75
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
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
Comments
' {$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]
sorry but i tried serval way i still i couldn't find away could u tell me!!!!
SEROUT 0, 84,["B",B,13,10]
This will send the character "B", then it will send the lower 8 bits of the variable B as a single byte, then it will send a carriage return (13) and line feed (10). I don't know if the modem requires the line feed. Most do not. They'll use the carriage return as the end of the command, then ignore the line feed.
What do you want the modem to get? It's impossible to tell from your code or your description.
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....
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]
' {$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
for example i wanna the stamp to accept "A", "B", "C" letter which i send from my phone and received from the model!!!
thx
but what will be the serout command????????
thx