TC35 Port High

Hello together,

these are my first steps with the Arduino. I want to do the folowing.

my gsm TC35 gets an sms then a port on the Arduino get high.

Can someone explain me wat i have to write?

Satalaner:
Can someone explain me wat i have to write?

Some code.

sure but can some give me an example code? send an sms is no problem but i dont know how to receive

Satalaner:
sure but can some give me an example code? send an sms is no problem but i dont know how to receive

What have you tried? DO you have any code?

thanks for your answer.
This is the code to send an sms.

#include <SoftwareSerial.h>
#define rxPin 9
#define txPin 8
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
char text[150];
String message="";
int i;

void setup(){

pinMode(10,OUTPUT);
Serial.begin(9600);
while (!Serial){}
mySerial.begin(9600);
digitalWrite(10,0);
delay(1000);
digitalWrite(10,1);
Serial.println("Write your SMS:");
}

void loop(){

i=0;
while( Serial.available()>0 ){
text = Serial.read(); *
_message += text
; _
*i++; *
*if (text[i-1]==46){ *
_
Serial.println("Send SMS......"); _
_
SendTextMessage(); _
_
ShowSerialData(); _
_
delay(1000); _
_
Serial.println("\r");_
_
Serial.println("Success"); _
_
message=""; _
_
i=0; }}} *_
void SendTextMessage(){

mySerial.print("AT+CMGF=1\r");
*delay(1000); *
*mySerial.print("AT+CMGS="+491781234567"\r"); *
*delay(1000); *
*mySerial.println(message); *
*mySerial.print("\r"); *
*delay(1000); *
*mySerial.println((char)26); *
*mySerial.println(); } *
*void ShowSerialData(){ *
*while(mySerial.available()!=0) *
*Serial.write(mySerial.read());} *

now i have this code but nothing happened when i ride an sms with ON
i hope someone can help me

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9);
int dp=0;
int i=0;
int dpLed=0;
char c;
String message="";
String Res="";
String TxtSms="";
String NumSms="";
String cReturn="";
int nReturn=0;
int nPremier=0;
//--Pin of the LEDs
int ledPinRel = 5; //-- Led Action Or Relay
int ledPinOk = 4; //-- Led OK
int ledPinErr = 3; //-- Led Error
void setup()
{
mySerial.begin(9600);
delay(5000);
//-- SMS in text mode
message="AT+CMGF=1";
SendCmdMessage();
ShowSerialData();
//-- Print storage status
message="AT+CPMS="SM"";
SendCmdMessage();
ExtractSmsNumber();
//--Delete all the SMS
for (i=nReturn; i>0; i--)
{ message="";
message=i+message;
message="AT+CMGD="+message;
SendCmdMessage();
ShowSerialData();
}
//-- Print storage status
message="AT+CPMS="SM"";
SendCmdMessage();
ExtractSmsNumber();
nPremier=nReturn;
//-- Initialize LED PIN
pinMode( ledPinRel, OUTPUT );
digitalWrite( ledPinRel, LOW);
pinMode( ledPinErr, OUTPUT );
digitalWrite( ledPinErr, LOW);
pinMode( ledPinOk, OUTPUT );
digitalWrite( ledPinOk, HIGH);
}
void loop()
{
message="AT+CPMS="SM"";
SendCmdMessage();
ExtractSmsNumber();
dp=0;
if (nReturn>nPremier)
{//--Read the nReturn message
message="";
message=nReturn+message;
message="AT+CMGR="+message;
SendCmdMessage();
ShowSmsData();
if (TxtSms=="ON")
dp=1;
if (TxtSms=="OFF")
dp=2;
if (TxtSms=="?")
dp=3;
switch (dp) {
case 1 :
{digitalWrite( ledPinRel, HIGH);
dpLed=1;
break;}
case 2 :
{digitalWrite( ledPinRel, LOW);
dpLed=0;
break;}
case 3 :
{if (dpLed==1)
message="La LED est ON";
else
message="La LED est OFF";
SendSms();
message="AT+CMGD=1";
SendCmdMessage();
ShowSerialData();
break;
}
default :
{message="Erreur, tapez ON, OFF ou ?, merci !";
SendSms();
message="AT+CMGD=1";
SendCmdMessage();
ShowSerialData();
break;}
}
//--Delete the nReturn message
message="";
message=nReturn+message;
message="AT+CMGD="+message;
SendCmdMessage();
ShowSerialData();
delay(1000);
}
}
void ExtractSmsNumber()
{cReturn="";
Res="";
nReturn=1;
dp=0;
while(mySerial.available()!=0)
{
c=char(mySerial.read());
//if ((c!=13) && (c!=10))
// Res+=c;
switch(dp){
case 1 :
if (c==44)///-- Acii code for Comma
dp=2;
else
Res+=c;
break;
case 2 :
if (Res!="")
{ Res.trim();
cReturn=Res;
if (cReturn.length()==1)
{c=cReturn.charAt(0);
nReturn=c-0;
nReturn=nReturn-48;}
else
nReturn=0;
}
dp=0;
Res="";
break;
default :
if (c==58) //-- Acii code for :
dp=1;
break;
}
}
Res.toUpperCase();
if (Res.indexOf("OK")>0)
{digitalWrite( ledPinOk, HIGH);
digitalWrite( ledPinErr, LOW);
}
if (Res.indexOf("ERROR")>0)
{digitalWrite( ledPinOk, LOW);
digitalWrite( ledPinErr, HIGH);
}
}
void ShowSmsData()
//-- Read the sender number (NumSms) and the text message (TxtSms)
//-- The return code format is : [+CMGR: "REC READ","+336xxxxxxxx",,"13/06/10,22:18:35+08"Message]
{dp=0;
TxtSms="";
NumSms="";
Res="";
while(mySerial.available()!=0)
{
c=char(mySerial.read());
if ((c!=13) && (c!=10))
Res+=c;
if ((c==44) && (dp==0))///-- 44 Ascii code for ','
{//-- Entering Phone Number
c=char(mySerial.read()); //-- Reading '"'
c=char(mySerial.read());
dp=1;}
if ((c==34) && (dp==1))///-- 34 Ascii code for '"'
{//-- Leaving Phone Number
dp=2;}
if ((c==13) && (dp==2))///-- 13 Ascii code for
{//-- Entering Message zone
c=char(mySerial.read()); //-- Reading
dp=3;}
if ((c==13) && (dp==3))///-- 13 Ascii code for
{//-- Leaving Message zone
dp=4;}
switch(dp){
case 1 :
NumSms+=c;
break;
case 3 :
TxtSms+=c;
break;
}
}
TxtSms.toUpperCase();
TxtSms.trim();
Res.toUpperCase();
if (Res.indexOf("OK")>0)
{digitalWrite( ledPinOk, HIGH);
digitalWrite( ledPinErr, LOW);
}
if (Res.indexOf("ERROR")>0)
{digitalWrite( ledPinOk, LOW);
digitalWrite( ledPinErr, HIGH);
}
}
void SendSms()
{
mySerial.println("AT+CMGS="+NumSms);
delay(1000);
mySerial.println(message);
delay(1000);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(1000);
ShowSerialData();
delay(1000);
}
void SendCmdMessage()
{
mySerial.println(message);
delay(1000);
}
void ShowSerialData()
{Res="";
while(mySerial.available()!=0)
{c=char(mySerial.read());
if ((c!=13) && (c!=10))
Res+=c;
}
Res.toUpperCase();
if (Res.indexOf("OK")>0)
{digitalWrite( ledPinOk, HIGH);
digitalWrite( ledPinErr, LOW);
}
if (Res.indexOf("ERROR")>0)
{digitalWrite( ledPinOk, LOW);
digitalWrite( ledPinErr, HIGH);
}
}